cleanup: simplify code by using FList.singleton(x) instead of emptyList().prepend(x) calls

GitOrigin-RevId: 392f25f5b034e1e087e48de6e0032593b7b15eae
This commit is contained in:
Nikolay Chashnikov
2023-10-12 15:55:35 +02:00
committed by intellij-monorepo-bot
parent 7cd70b1731
commit 672cebe49c
5 changed files with 9 additions and 9 deletions

View File

@@ -167,7 +167,7 @@ public final class KShortestPathsFinder<Node> {
final Heap<Node> heap = myHeaps.get(myStart);
if (heap != null) {
queue.add(new Sidetracks<>(0, FList.<HeapNode<Node>>emptyList().prepend(heap.getRoot())));
queue.add(new Sidetracks<>(0, FList.singleton(heap.getRoot())));
for (int i = 2; i <= k; i++) {
if (queue.isEmpty()) break;
myProgressIndicator.checkCanceled();

View File

@@ -233,12 +233,12 @@ final class MinusculeMatcherImpl extends MinusculeMatcher {
if (infix) {
int index = Strings.indexOfIgnoreCase(name, new CharArrayCharSequence(patternWithoutWildChar, 0, patternWithoutWildChar.length), 0);
if (index >= 0) {
return FList.<TextRange>emptyList().prepend(TextRange.from(index, patternWithoutWildChar.length - 1));
return FList.singleton(TextRange.from(index, patternWithoutWildChar.length - 1));
}
return null;
}
if (CharArrayUtil.regionMatches(patternWithoutWildChar, 0, patternWithoutWildChar.length, name)) {
return FList.<TextRange>emptyList().prepend(new TextRange(0, patternWithoutWildChar.length));
return FList.singleton(new TextRange(0, patternWithoutWildChar.length));
}
return null;
}
@@ -280,7 +280,7 @@ final class MinusculeMatcherImpl extends MinusculeMatcher {
if (isTrailingSpacePattern() && nameIndex != name.length() && (patternIndex < 2 || !isUpperCaseOrDigit(myPattern[patternIndex - 2]))) {
int spaceIndex = name.indexOf(' ', nameIndex);
if (spaceIndex >= 0) {
return FList.<TextRange>emptyList().prepend(TextRange.from(spaceIndex, 1));
return FList.singleton(TextRange.from(spaceIndex, 1));
}
return null;
}
@@ -430,7 +430,7 @@ final class MinusculeMatcherImpl extends MinusculeMatcher {
boolean isAsciiName,
int fragmentLength, int minFragment) {
if (patternIndex + fragmentLength >= myPattern.length) {
return FList.<TextRange>emptyList().prepend(TextRange.from(nameIndex, fragmentLength));
return FList.singleton(TextRange.from(nameIndex, fragmentLength));
}
// try to match the remainder of pattern with the remainder of name

View File

@@ -492,7 +492,7 @@ public final class PinyinMatcher extends MinusculeMatcher {
int maxOffset = name.length() - myPattern.length();
for (int start = 0; start <= maxOffset; start++) {
if (hasMatchAt(name, start)) {
return FList.<TextRange>emptyList().prepend(TextRange.create(start, start + myPattern.length()));
return FList.singleton(TextRange.create(start, start + myPattern.length()));
}
}
return null;

View File

@@ -343,7 +343,7 @@ final class TypoTolerantMatcher extends MinusculeMatcher {
patternIndex - 2, errorState)))) {
int spaceIndex = myName.indexOf(' ', nameIndex);
if (spaceIndex >= 0) {
return FList.<TextRange>emptyList().prepend(new Range(spaceIndex, spaceIndex + 1, 0));
return FList.singleton(new Range(spaceIndex, spaceIndex + 1, 0));
}
return null;
}
@@ -546,7 +546,7 @@ final class TypoTolerantMatcher extends MinusculeMatcher {
if (patternIndex + fragmentLength >= patternLength(errorState)) {
int errors = errorState.countErrors(patternIndex, patternIndex + fragmentLength);
if (errors == fragmentLength) return null;
return FList.<TextRange>emptyList().prepend(new Range(nameIndex, nameIndex + fragmentLength, errors));
return FList.singleton(new Range(nameIndex, nameIndex + fragmentLength, errors));
}
// try to match the remainder of pattern with the remainder of name

View File

@@ -54,7 +54,7 @@ public final class TextMateLexer {
myText = text;
myCurrentOffset = startOffset;
myStates = FList.<TextMateLexerState>emptyList().prepend(myLanguageInitialState);
myStates = FList.singleton(myLanguageInitialState);
myCurrentScope = new TextMateScope(myLanguageScopeName, null);
}