memory: intern frequent type text in cls references

This commit is contained in:
Alexey Kudravtsev
2013-05-13 15:28:39 +04:00
parent bd1f3e393d
commit c4e748d974
3 changed files with 13 additions and 7 deletions
@@ -65,8 +65,10 @@ public class TypeInfo {
"null",
"short",
"void",
CommonClassNames.JAVA_LANG_OBJECT_SHORT, CommonClassNames.JAVA_LANG_OBJECT,
CommonClassNames.JAVA_LANG_STRING_SHORT, CommonClassNames.JAVA_LANG_STRING
CommonClassNames.JAVA_LANG_OBJECT_SHORT,
CommonClassNames.JAVA_LANG_OBJECT,
CommonClassNames.JAVA_LANG_STRING_SHORT,
CommonClassNames.JAVA_LANG_STRING
};
ourFrequentTypeIndex = new TObjectIntHashMap<String>();
@@ -273,11 +275,11 @@ public class TypeInfo {
buf.append("...");
}
return buf.toString();
return internFrequentType(buf.toString());
}
@NotNull
private static String internFrequentType(@NotNull String type) {
public static String internFrequentType(@NotNull String type) {
int frequentIndex = ourFrequentTypeIndex.get(type);
return frequentIndex == 0 ? type : ourIndexFrequentType[frequentIndex];
}
@@ -20,6 +20,7 @@ import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.*;
import com.intellij.psi.impl.PsiSubstitutorImpl;
import com.intellij.psi.impl.cache.TypeInfo;
import com.intellij.psi.impl.source.resolve.ResolveCache;
import com.intellij.psi.impl.source.tree.JavaElementType;
import com.intellij.psi.impl.source.tree.TreeElement;
@@ -45,8 +46,10 @@ public class ClsJavaCodeReferenceElementImpl extends ClsElementImpl implements P
public ClsJavaCodeReferenceElementImpl(PsiElement parent, String canonicalText) {
myParent = parent;
myCanonicalText = canonicalText;
myQualifiedName = PsiNameHelper.getQualifiedClassName(myCanonicalText, false);
String canonical = TypeInfo.internFrequentType(canonicalText);
myCanonicalText = canonical;
String qName = TypeInfo.internFrequentType(PsiNameHelper.getQualifiedClassName(myCanonicalText, false));
myQualifiedName = qName.equals(canonical) ? canonical : qName;
String[] classParameters = PsiNameHelper.getClassParametersText(canonicalText);
myRefParameterList = classParameters.length == 0 ? null : new ClsReferenceParameterListImpl(this, classParameters);
@@ -17,6 +17,7 @@ package com.intellij.psi.impl.compiled;
import com.intellij.psi.*;
import com.intellij.psi.impl.PsiImplUtil;
import com.intellij.psi.impl.cache.TypeInfo;
import com.intellij.psi.impl.source.PsiClassReferenceType;
import com.intellij.psi.impl.source.tree.JavaElementType;
import com.intellij.psi.impl.source.tree.TreeElement;
@@ -40,7 +41,7 @@ public class ClsTypeElementImpl extends ClsElementImpl implements PsiTypeElement
public ClsTypeElementImpl(@NotNull PsiElement parent, @NotNull String typeText, char variance) {
myParent = parent;
myTypeText = typeText;
myTypeText = TypeInfo.internFrequentType(typeText);
myVariance = variance;
}