[PATCH] D112052: [ADT] Add Compare template param to EquivalenceClasses
Alex Zinenko via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 19 06:10:07 PDT 2021
ftynse added inline comments.
================
Comment at: llvm/include/llvm/ADT/EquivalenceClasses.h:106
+ bool operator<(const ECValue &UFN) const {
+ return Compare()(Data, UFN.Data);
+ }
----------------
It feels expensive to construct the comparator object on each call to `operator<`. Caching it in the `ECValue` isn't really a good option because it will consume a lot of space, even if we only keep a reference to the comparator stored in the `EquivalenceClassses`. Can't we just pass the template parameter down to `std::set`, potentially wrapped in some extra class? AFAIK, the set implementation will only keep one copy of the comparator.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D112052/new/
https://reviews.llvm.org/D112052
More information about the llvm-commits
mailing list