Skip to content

Commit e65c299

Browse files
committed
performance! compute LookupElement hashCode
1 parent bdaa105 commit e65c299

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/main/java/com/tang/intellij/lua/editor/completion/LookupElement.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ class LuaFieldLookupElement(val fieldName: String, val field: LuaClassField, bol
102102

103103
class TyFunctionLookupElement(name: String,
104104
val psi: LuaPsiElement,
105-
signature: IFunSignature,
105+
private val signature: IFunSignature,
106106
bold: Boolean,
107107
colonStyle: Boolean,
108108
val ty: ITyFunction,
@@ -133,6 +133,10 @@ class TyFunctionLookupElement(name: String,
133133

134134
override fun getItemText() = lazyItemText
135135

136+
override fun hashCode(): Int {
137+
return super.hashCode() * 31 * (signature.params.size + 1)
138+
}
139+
136140
/**
137141
* https://github.com/tangzx/IntelliJ-EmmyLua/issues/54
138142
*/

src/main/java/com/tang/intellij/lua/editor/completion/LuaLookupElement.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ public int compareTo(@NotNull final LookupElement o) {
162162
public boolean equals(Object obj) {
163163
if (obj instanceof LuaLookupElement) {
164164
LuaLookupElement element = (LuaLookupElement) obj;
165-
return element.getItemText().equals(getItemText());
165+
return element.hashCode() == hashCode();
166166
}
167167
return super.equals(obj);
168168
}

0 commit comments

Comments
 (0)