[PATCH] D49596: [Support] Add a UniqueStringSaver: like StringSaver, but deduplicating.
Haojian Wu via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 20 06:54:35 PDT 2018
hokein added a comment.
Thanks!
================
Comment at: lib/Support/StringSaver.cpp:26
+ S = Strings.save(S);
+ if (!Unique.insert(S).second)
+ llvm_unreachable("Failed to insert into unique table - race?");
----------------
While we have nice assertion message here, but in return we pay an extra lookup cost. I think we should avoid it (this function is likely to be used in hot path).
Maybe just
```
auto It = Unique.insert(S);
if (It.second) {
*It.first = Strings.save(V);
}
return *It.first.
```
Repository:
rL LLVM
https://reviews.llvm.org/D49596
More information about the llvm-commits
mailing list