[libcxx-commits] [PATCH] D61878: Change how containers are compared

Zoe Carver via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Thu May 16 11:26:13 PDT 2019


zoecarver marked 2 inline comments as done.
zoecarver added inline comments.


================
Comment at: benchmarks/unordered_set_comp.bench.cpp:82
+bool
+new_comp(const std::unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
+         const std::unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
----------------
ldionne wrote:
> This should be extracted into an implementation-detail function and used in both the headers and this benchmark, instead of copy-pasting.
Actually, I could probably just use `operator==` here. 


================
Comment at: include/unordered_set:1535
+    auto __first2 = __y.begin();
+    for (; __first1 != __last1; ++__first1, (void) ++__first2)
+        if (!(*__first1 == *__first2))
----------------
ldionne wrote:
> That's basically equivalent to:
> 
> ```
> bool res = std::equal(__first1, __last1, __first2);
> if (res)
>   return true;
> 
> // rest of the code after __not_done label
> ```
> 
> Or did I miss something? If they're equivalent, I suggest we remove the raw loop.
No, that would not be the same. This function does not check if the sets are the same; it removes any parts of the sets that are the same. Importantly, if only three elements are the same, it will "chop off" those elements and //continue// from the third element below. Does that make sense? 


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