mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
CompletionResultSet/CamelHumpMatcher: reuse existing objects when possible instead of copying
This commit is contained in:
@@ -87,6 +87,10 @@ public class CamelHumpMatcher extends PrefixMatcher {
|
||||
@Override
|
||||
@NotNull
|
||||
public PrefixMatcher cloneWithPrefix(@NotNull final String prefix) {
|
||||
if (prefix.equals(myPrefix)) {
|
||||
return this;
|
||||
}
|
||||
|
||||
return new CamelHumpMatcher(prefix, myCaseSensitive);
|
||||
}
|
||||
|
||||
|
||||
+5
-1
@@ -143,6 +143,10 @@ public final class CompletionServiceImpl extends CompletionService {
|
||||
@Override
|
||||
@NotNull
|
||||
public CompletionResultSet withPrefixMatcher(@NotNull final PrefixMatcher matcher) {
|
||||
if (matcher.equals(getPrefixMatcher())) {
|
||||
return this;
|
||||
}
|
||||
|
||||
return new CompletionResultSetImpl(getConsumer(), myLengthOfTextBeforePosition, matcher, myContributor, myParameters, mySorter, this);
|
||||
}
|
||||
|
||||
@@ -160,7 +164,7 @@ public final class CompletionServiceImpl extends CompletionService {
|
||||
@Override
|
||||
@NotNull
|
||||
public CompletionResultSet withPrefixMatcher(@NotNull final String prefix) {
|
||||
return withPrefixMatcher(new CamelHumpMatcher(prefix));
|
||||
return withPrefixMatcher(getPrefixMatcher().cloneWithPrefix(prefix));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
Reference in New Issue
Block a user