[libcxx-commits] [PATCH] D61771: Comparing Unordered Containers (P0809)
Zoe Carver via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Sat May 11 09:40:45 PDT 2019
zoecarver marked an inline comment as done.
zoecarver added inline comments.
================
Comment at: include/unordered_map:2274
return false;
- typedef typename unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::const_iterator
- const_iterator;
- typedef pair<const_iterator, const_iterator> _EqRng;
- for (const_iterator __i = __x.begin(), __ex = __x.end(); __i != __ex;)
- {
- _EqRng __xeq = __x.equal_range(__i->first);
- _EqRng __yeq = __y.equal_range(__i->first);
- if (_VSTD::distance(__xeq.first, __xeq.second) !=
- _VSTD::distance(__yeq.first, __yeq.second) ||
- !_VSTD::is_permutation(__xeq.first, __xeq.second, __yeq.first))
- return false;
- __i = __xeq.second;
- }
- return true;
+ return _VSTD::is_permutation(__x.begin(), __x.end(), __y.begin());
}
----------------
>From my tests, simply using `is_permutation` here is quite a bit faster than the previous method of comparison. I think that both bits of code are functionally equivalent (but let me know if that is not the case).
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D61771/new/
https://reviews.llvm.org/D61771
More information about the libcxx-commits
mailing list