[libcxx-commits] [PATCH] D61878: Use is_permutation when comparing containers

Marshall Clow via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Mon May 13 17:59:04 PDT 2019


mclow.lists added a comment.

I am quite surprised by the idea that a naked `is_permutation` can outperform the existing implementation.
However, the test that you linked to is definitely faster on my machine.

I think that result is something that needs to go into our benchmark suite.



================
Comment at: include/unordered_map:1654
+        if (__found == __y.end() || !(*__found == *__i))
             return false;
     }
----------------
This seems odd to me. 

The old code cached both `__x.end()` and `__y.end()`.
The new code caches only `__x.end()`.

Why?
Either it's worth caching `end()` or it is not.



================
Comment at: include/unordered_set:960
         return false;
-    typedef typename unordered_set<_Value, _Hash, _Pred, _Alloc>::const_iterator
-                                                                 const_iterator;
-    for (const_iterator __i = __x.begin(), __ex = __x.end(), __ey = __y.end();
-            __i != __ex; ++__i)
+    typedef
+        typename unordered_set<_Value, _Hash, _Pred, _Alloc>::const_iterator
----------------
Same comment as in `unordered_map`


Repository:
  rCXX libc++

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

https://reviews.llvm.org/D61878





More information about the libcxx-commits mailing list