================
@@ -70,16 +93,37 @@ class ParentMapContext::ParentMap {
push_back(Value);
}
bool contains(const DynTypedNode &Value) {
- return Seen.contains(Value);
+ assert(Value.getMemoizationData());
+ bool found = FragileLazySeenCache.contains(&Value);
+ while (!found && ItemsProcessed < Items.size()) {
+ found |= FragileLazySeenCache.insert(&Items[ItemsProcessed]).second;
+ ++ItemsProcessed;
+ }
+ return found;
}
void push_back(const DynTypedNode &Value) {
- if (!Value.getMemoizationData() || Seen.insert(Value).second)
+ if (!Value.getMemoizationData() || !contains(Value)) {
----------------
erichkeane wrote:
It seems unfortunate to potentially re-calculate in `contains` here to just
potentially immediately re-calculate it. I wonder if there is value to
special-case `ItemsProcessed == 0 && Items.capacity() == Items.size()` to just
do a linear search?
Also-also--- I wonder if it makes sense to only do the cache when `size()` is
significant enough? It would be interesting to see if there is a value of N
under which the set doesn't really make sense.
https://github.com/llvm/llvm-project/pull/129934
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits