idea: do not call prefix matcher in loop if prefix is empty

This commit is contained in:
Stepan Koltsov
2012-06-17 05:55:24 +04:00
parent 554a54bcc5
commit b0f98711a0
@@ -349,15 +349,23 @@ public class JetCompletionContributor extends CompletionContributor {
(JetFile)reference.getExpression().getContainingFile()) (JetFile)reference.getExpression().getContainingFile())
.getBindingContext(); .getBindingContext();
class PrefixMatcherNamePredicate extends NamePredicate { final PrefixMatcher prefixMatcher = result.getPrefixMatcher();
@Override
public boolean matches(@NotNull Name name) { NamePredicate namePredicate;
return result.getPrefixMatcher().prefixMatches(name.getName()); if (prefixMatcher.getPrefix().length() == 0) {
namePredicate = NamePredicate.all();
} else {
class PrefixMatcherNamePredicate extends NamePredicate {
@Override
public boolean matches(@NotNull Name name) {
return prefixMatcher.prefixMatches(name.getName());
}
} }
namePredicate = new PrefixMatcherNamePredicate();
} }
Collection<DeclarationDescriptor> descriptors = TipsManager.getReferenceVariants( Collection<DeclarationDescriptor> descriptors = TipsManager.getReferenceVariants(
reference.getExpression(), bindingContext, new PrefixMatcherNamePredicate()); reference.getExpression(), bindingContext, namePredicate);
Collection<DeclarationDescriptor> checkedDescriptors = Collections2.filter(descriptors, new Predicate<DeclarationDescriptor>() { Collection<DeclarationDescriptor> checkedDescriptors = Collections2.filter(descriptors, new Predicate<DeclarationDescriptor>() {
@Override @Override