[PATCH] D132334: [ADT] Add all_equal predicate
Will Dietz via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 8 14:31:18 PDT 2022
dtzWill added a comment.
Small question about usage of `std::equal` here, if you don't mind? Thanks!
================
Comment at: llvm/include/llvm/ADT/STLExtras.h:1770
+ auto End = adl_end(Range);
+ return Begin == End || std::equal(Begin + 1, End, Begin);
+}
----------------
Hi! Just wondering, why does this use `std::equal`-- which compares ranges (here, range of [2nd to last] vs [1st to (last-1)])-- instead of something like `llvm::all_of(Range,[&](auto x)(return x == *Begin;)`?
Does this have advantages? Seems slightly more expensive this way, is why I'm asking, but I haven't bounced through the generated code or such.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D132334/new/
https://reviews.llvm.org/D132334
More information about the llvm-commits
mailing list