From e4f7dd08d7b74bd515703d1e34f8750bd7e85576 Mon Sep 17 00:00:00 2001 From: peter Date: Thu, 3 Jul 2014 16:01:43 +0200 Subject: [PATCH] MinusculeMatcher: don't make grand claims about slowness on the basis of just one measurement --- .../psi/codeStyle/MinusculeMatcher.java | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) 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; } /**