diff --git a/platform/util/src/com/intellij/psi/codeStyle/MinusculeMatcher.java b/platform/util/src/com/intellij/psi/codeStyle/MinusculeMatcher.java index 4e22c74f5fa5..2ffda700808b 100644 --- a/platform/util/src/com/intellij/psi/codeStyle/MinusculeMatcher.java +++ b/platform/util/src/com/intellij/psi/codeStyle/MinusculeMatcher.java @@ -215,8 +215,7 @@ public class MinusculeMatcher implements Matcher { } @Nullable - public FList matchingFragments(@NotNull String name) { - long start = System.currentTimeMillis(); + private FList calcMatchingFragments(@NotNull String name) { MatchingState state = myMatchingState.get(); state.initializeState(name); try { @@ -224,12 +223,23 @@ public class MinusculeMatcher implements Matcher { } finally { state.releaseState(); - if (System.currentTimeMillis() - start > 1000 && - // if there's little free memory, it might have been the gc affecting the performance - Runtime.getRuntime().freeMemory() > Runtime.getRuntime().totalMemory() * 3 / 10) { - LOG.error("Too long matching: name=" + name + "; prefix=" + new String(myPattern)); + } + } + + @Nullable + public FList matchingFragments(@NotNull String name) { + long start = System.currentTimeMillis(); + FList result = calcMatchingFragments(name); + if (System.currentTimeMillis() - start > 1000 && + // if there's little free memory, it might have been the gc affecting the performance + Runtime.getRuntime().freeMemory() > Runtime.getRuntime().totalMemory() * 3 / 10) { + start = System.currentTimeMillis(); + calcMatchingFragments(name); + if (System.currentTimeMillis() - start > 1000) { + LOG.error("Too long name matching: name=" + name + "; prefix=" + new String(myPattern)); } } + return result; } /**