mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 15:19:59 +07:00
IJPL-157271: performance experiment: avoid synchronized in c.i.o.fileTypes.WildcardFileNameMatcher.RegexpMatcher
This will produce more very short-living garbage which looks harmless. Matcher class has about 20 fields inside. Keep aside that some of them are arrays, Matcher probably occupies 100-150 bytes in the memory. I.e. there will be 150-225MB of garbage for mid-size project like idea ultimate (~1.5M files). Looks acceptable, because preliminary experiments showed that this will decrease 2nd scanning by ~10% (10sec -> 9sec) because of better parallelization when indexing on 19 threads. More parallel environments (like dev pods) should probably show even better parallelization. GitOrigin-RevId: 450ccf3105d31be2703e4da859a59f1ee6351b8e
This commit is contained in:
committed by
intellij-monorepo-bot
parent
31cf45c829
commit
ffd202ba96
@@ -5,7 +5,7 @@ import com.intellij.openapi.util.text.Strings;
|
||||
import com.intellij.util.PatternUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class WildcardFileNameMatcher implements FileNameMatcher {
|
||||
private final String myPattern;
|
||||
@@ -16,18 +16,15 @@ public class WildcardFileNameMatcher implements FileNameMatcher {
|
||||
}
|
||||
|
||||
private static final class RegexpMatcher implements MaskMatcher {
|
||||
private final Matcher myMatcher;
|
||||
private final Pattern pattern;
|
||||
|
||||
RegexpMatcher(@NotNull String pattern) {
|
||||
myMatcher = PatternUtil.fromMask(pattern).matcher("");
|
||||
this.pattern = PatternUtil.fromMask(pattern);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(final @NotNull CharSequence filename) {
|
||||
synchronized (myMatcher) {
|
||||
myMatcher.reset(filename);
|
||||
return myMatcher.matches();
|
||||
}
|
||||
return pattern.matcher(filename).matches();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user