performance optimizations for lookup with many items:

- avoid expensive Class#isInstanceOf of LookupElement sublcasses #as using specialized <SpecificLookupItem> #from with explicit instanceof SpecificLookupItem
- using identity hashing for binding lookup item weights to item
This commit is contained in:
Maxim.Mossienko
2010-04-23 14:37:32 +04:00
parent dd03a78a0d
commit 5e74a8b399
10 changed files with 48 additions and 11 deletions
@@ -784,7 +784,7 @@ public class JavaCompletionUtil {
@Nullable
public static PsiType getLookupElementType(final LookupElement element) {
final TypedLookupItem typed = element.as(TypedLookupItem.class);
TypedLookupItem typed = typedFrom(element);
if (typed != null) {
return typed.getType();
}
@@ -805,6 +805,16 @@ public class JavaCompletionUtil {
return qualifierType;
}
public static @Nullable TypedLookupItem typedFrom(LookupElement element) {
TypedLookupItem typed = null;
if (element instanceof TypedLookupItem) typed = (TypedLookupItem)element;
else if (element instanceof LookupElementDecorator) {
element = ((LookupElementDecorator)element).getDelegate();
if (element instanceof TypedLookupItem) typed = (TypedLookupItem)element;
}
return typed;
}
@Nullable
public static PsiType getQualifiedMemberReferenceType(@Nullable PsiType qualifierType, @NotNull final PsiMember member) {
final ClassCandidateInfo info = TypeConversionUtil.splitType(qualifierType, member);