mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
use identity map for more efficient dfa state copy lookup
This commit is contained in:
@@ -38,7 +38,7 @@ import java.util.Set;
|
||||
class StateMerger {
|
||||
private final Map<DfaMemoryStateImpl, Map<DfaVariableValue, DfaConstValue>> myVarValues = ContainerUtil.newIdentityHashMap();
|
||||
private final Map<DfaMemoryStateImpl, List<UnorderedPair<DfaValue>>> myEqPairs = ContainerUtil.newIdentityHashMap();
|
||||
private final Map<Pair<DfaMemoryStateImpl, DfaVariableValue>, DfaMemoryStateImpl> myCopyCache = ContainerUtil.newHashMap();
|
||||
private final Map<DfaMemoryState, Map<DfaVariableValue, DfaMemoryStateImpl>> myCopyCache = ContainerUtil.newIdentityHashMap();
|
||||
|
||||
@Nullable
|
||||
public List<DfaMemoryStateImpl> mergeByEquality(List<DfaMemoryStateImpl> states) {
|
||||
@@ -197,12 +197,15 @@ class StateMerger {
|
||||
}
|
||||
|
||||
private DfaMemoryStateImpl copyWithoutVar(DfaMemoryStateImpl state, DfaVariableValue var) {
|
||||
Pair<DfaMemoryStateImpl, DfaVariableValue> key = Pair.create(state, var);
|
||||
DfaMemoryStateImpl copy = myCopyCache.get(key);
|
||||
Map<DfaVariableValue, DfaMemoryStateImpl> map = myCopyCache.get(state);
|
||||
if (map == null) {
|
||||
myCopyCache.put(state, map = ContainerUtil.newIdentityHashMap());
|
||||
}
|
||||
DfaMemoryStateImpl copy = map.get(var);
|
||||
if (copy == null) {
|
||||
copy = state.createCopy();
|
||||
copy.flushVariable(var);
|
||||
myCopyCache.put(key, copy);
|
||||
map.put(var, copy);
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user