mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
MinusculeMatcher: don't make grand claims about slowness on the basis of just one measurement
This commit is contained in:
@@ -215,8 +215,7 @@ public class MinusculeMatcher implements Matcher {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public FList<TextRange> matchingFragments(@NotNull String name) {
|
||||
long start = System.currentTimeMillis();
|
||||
private FList<TextRange> 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<TextRange> matchingFragments(@NotNull String name) {
|
||||
long start = System.currentTimeMillis();
|
||||
FList<TextRange> 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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user