mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[vcs-log] speed up filtering with index by text filter with multiple patterns
IDEA-130970
This commit is contained in:
@@ -29,6 +29,7 @@ import com.intellij.vcs.log.*;
|
||||
import com.intellij.vcs.log.data.VcsLogStorage;
|
||||
import com.intellij.vcs.log.history.FileNamesData;
|
||||
import com.intellij.vcs.log.impl.FatalErrorHandler;
|
||||
import com.intellij.vcs.log.ui.filter.VcsLogMultiplePatternsTextFilter;
|
||||
import com.intellij.vcs.log.util.TroveUtil;
|
||||
import com.intellij.vcsUtil.VcsUtil;
|
||||
import gnu.trove.TIntHashSet;
|
||||
@@ -194,30 +195,33 @@ public class IndexDataGetter {
|
||||
|
||||
@NotNull
|
||||
private TIntHashSet filterMessages(@NotNull VcsLogTextFilter filter) {
|
||||
if (!filter.isRegex()) {
|
||||
if (!filter.isRegex() || filter instanceof VcsLogMultiplePatternsTextFilter) {
|
||||
TIntHashSet resultByTrigrams = executeAndCatch(() -> {
|
||||
|
||||
TIntHashSet commitsForSearch = myIndexStorage.trigrams.getCommitsForSubstring(filter.getText());
|
||||
if (commitsForSearch != null) {
|
||||
TIntHashSet result = new TIntHashSet();
|
||||
commitsForSearch.forEach(commit -> {
|
||||
try {
|
||||
String value = myIndexStorage.messages.get(commit);
|
||||
if (value != null) {
|
||||
if (filter.matches(value)) {
|
||||
result.add(commit);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (IOException e) {
|
||||
myFatalErrorsConsumer.consume(this, e);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
return result;
|
||||
List<String> trigramSources = filter instanceof VcsLogMultiplePatternsTextFilter ?
|
||||
((VcsLogMultiplePatternsTextFilter)filter).getPatterns() :
|
||||
Collections.singletonList(filter.getText());
|
||||
TIntHashSet commitsForSearch = new TIntHashSet();
|
||||
for (String string : trigramSources) {
|
||||
TIntHashSet commits = myIndexStorage.trigrams.getCommitsForSubstring(string);
|
||||
if (commits == null) return null;
|
||||
TroveUtil.addAll(commitsForSearch, commits);
|
||||
}
|
||||
return null;
|
||||
TIntHashSet result = new TIntHashSet();
|
||||
commitsForSearch.forEach(commit -> {
|
||||
try {
|
||||
String value = myIndexStorage.messages.get(commit);
|
||||
if (value != null && filter.matches(value)) {
|
||||
result.add(commit);
|
||||
}
|
||||
}
|
||||
catch (IOException e) {
|
||||
myFatalErrorsConsumer.consume(this, e);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
return result;
|
||||
});
|
||||
|
||||
if (resultByTrigrams != null) return resultByTrigrams;
|
||||
|
||||
@@ -75,7 +75,7 @@ class VcsLogRegexTextFilter internal constructor(private val pattern: Pattern) :
|
||||
}
|
||||
}
|
||||
|
||||
class VcsLogMultiplePatternsTextFilter internal constructor(private val patterns: List<String>,
|
||||
class VcsLogMultiplePatternsTextFilter internal constructor(val patterns: List<String>,
|
||||
private val isMatchCase: Boolean) : VcsLogDetailsFilter, VcsLogTextFilter {
|
||||
override fun getText(): String = if (patterns.size == 1) patterns.single() else patterns.joinToString("|") { Pattern.quote(it) }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user