SSR inspection: avoid map.get with nontrivial equals/hashCode for each PSI element

This commit is contained in:
peter
2016-06-22 11:27:05 +02:00
parent 1313a268a9
commit 158c17c584
2 changed files with 7 additions and 3 deletions
@@ -115,8 +115,9 @@ public class SSBasedInspection extends LocalInspectionTool {
synchronized (LOCK) {
if (LexicalNodesFilter.getInstance().accepts(element)) return;
final SsrFilteringNodeIterator matchedNodes = new SsrFilteringNodeIterator(element);
for (Configuration configuration : myConfigurations) {
final MatchContext context = compiledOptions.get(configuration);
for (Map.Entry<Configuration, MatchContext> entry : compiledOptions.entrySet()) {
Configuration configuration = entry.getKey();
MatchContext context = entry.getValue();
if (MatcherImpl.checkIfShouldAttemptToMatch(context, matchedNodes)) {
final int nodeCount = context.getPattern().getNodeCount();
@@ -11,6 +11,8 @@ import org.jetbrains.annotations.NotNull;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* @author Eugene.Kudelevsky
@@ -28,7 +30,8 @@ public class SSBasedInspectionCompiledPatternsCache {
matcher.precompileOptions(configurations, cache);
project.putUserData(COMPILED_OPTIONS_KEY, cache);
}
return cache;
return configurations.stream().collect(Collectors.toMap(Function.identity(), cache::get));
}
private static boolean areConfigurationsInCache(@NotNull List<Configuration> configurations,