Skip to content

Commit 3b3f9b6

Browse files
CopilotCapsAdmin
andcommitted
Address code review: improve comments and simplify variable usage
Co-authored-by: CapsAdmin <[email protected]>
1 parent f057650 commit 3b3f9b6

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

nattlua/types/union.lua

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,8 @@ function META:GetHash(visited)--[[#: string]]
9999
end
100100

101101
table_sort(types)
102-
local hash = table_concat(types, "|")
103-
visited[self] = hash
104-
return hash
102+
visited[self] = table_concat(types, "|")
103+
return visited[self]--[[# as string]]
105104
end
106105

107106
local sort = function(a--[[#: string]], b--[[#: string]])
@@ -168,7 +167,7 @@ local function find_index(self--[[#: TUnion]], obj--[[#: any]])
168167
for i = 1, len do
169168
local v = data[i]--[[# as any]]
170169

171-
-- Early exit if types don't match
170+
-- Check type first before expensive Equal call
172171
if v.Type == obj_type and v:Equal(obj) then
173172
if obj_type ~= "function" or v:GetFunctionBodyNode() == obj:GetFunctionBodyNode() then
174173
return i

0 commit comments

Comments
 (0)