[libcxx-commits] [PATCH] D61771: Comparing Unordered Containers (P0809)

Marshall Clow via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Fri May 10 07:31:01 PDT 2019


mclow.lists added inline comments.


================
Comment at: include/unordered_map:1656
+        _EqRng __yeq = __y.equal_range(__i->first);
+        if (_VSTD::distance(__xeq.first, __xeq.second) !=
+                _VSTD::distance(__yeq.first, __yeq.second) ||
----------------
This can be simplified for `unordered_map`, because `unordered_map` requires unique keys.

You can just use `__y.find` instead of `equal_range` and a single (Still need `equal_range` etc for `unordered_multimap`, though)



================
Comment at: include/unordered_set:968
+    {
+        _EqRng __xeq = __x.equal_range(*__i);
+        _EqRng __yeq = __y.equal_range(*__i);
----------------
Like the `unordered_map` code, this can be made much simpler because there are unique keys.


================
Comment at: include/unordered_set:1006
+                _VSTD::distance(__yeq.first, __yeq.second) ||
+            !_VSTD::is_permutation(__xeq.first, __xeq.second, __yeq.first))
             return false;
----------------
No need for `is_permutation`, again.


Repository:
  rCXX libc++

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61771/new/

https://reviews.llvm.org/D61771





More information about the libcxx-commits mailing list