return matchesRecursively(Node, Matcher, Builder, MaxDepth, Traversal,
Bind);
- if (ResultCache.size() > MaxMemoizationEntries)
- ResultCache.clear();
std::pair<MemoizationMap::iterator, bool> InsertResult =
ResultCache.insert(std::make_pair(Key, MemoizedMatchResult()));
if (InsertResult.second) {
const DynTypedMatcher &Matcher,
BoundNodesTreeBuilder *Builder,
BindKind Bind) {
+ if (ResultCache.size() > MaxMemoizationEntries)
+ ResultCache.clear();
return memoizedMatchesRecursively(Node, Matcher, Builder, INT_MAX,
TK_AsIs, Bind);
}
const DynTypedMatcher &Matcher,
BoundNodesTreeBuilder *Builder,
AncestorMatchMode MatchMode) {
+ // Reset the cache outside of the recursive call to make sure we
+ // don't invalidate any iterators.
+ if (ResultCache.size() > MaxMemoizationEntries)
+ ResultCache.clear();
return memoizedMatchesAncestorOfRecursively(Node, Matcher, Builder,
MatchMode);
}
Key.MatcherID = Matcher.getID();
Key.Node = Node;
Key.BoundNodes = *Builder;
- if (ResultCache.size() > MaxMemoizationEntries)
- ResultCache.clear();
std::pair<MemoizationMap::iterator, bool> InsertResult =
ResultCache.insert(std::make_pair(Key, MemoizedMatchResult()));
if (InsertResult.second) {