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

Eric Fiselier via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Sun Jun 9 00:12:47 PDT 2019


EricWF added inline comments.


================
Comment at: benchmarks/unordered_set_comp.bench.cpp:217
+        bool val = new_comp(u1, u2);
+        benchmark::DoNotOptimize(val);
+    }
----------------
I would be very surprised if the compiler wasn't optimizing your benchmark to:

```
bool __cached_val = new_comp(u1, u2);
while (st.KeepRunning()) {
  bool val = __cached_val;
  DoNotOptimize(val);
}
```


================
Comment at: include/unordered_map:2275
+
+    auto __first1 = __x.begin();
+    auto __last1  = __x.end();
----------------
You can't use auto.


================
Comment at: include/unordered_map:2278
+    auto __first2 = __y.begin();
+    for (; __first1 != __last1; ++__first1, (void) ++__first2)
+        if (!(*__first1 == *__first2))
----------------
Use explicit braces to make the nesting here more visible.


================
Comment at: include/unordered_map:2280
+        if (!(*__first1 == *__first2))
+            goto __not_done;
+    return true;
----------------
You can write this without goto.


================
Comment at: include/unordered_map:2287
+            const_iterator;
+    typedef _VSTD::pair<const_iterator, const_iterator> _EqRng;
+    for (const_iterator __i = __first1; __i != __x.end();)
----------------
There's no need to quality pair here.


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

https://reviews.llvm.org/D61878





More information about the libcxx-commits mailing list