Skip to content

Commit fc2f257

Browse files
committed
Cache an array length to avoid recomputing
1 parent 2087a06 commit fc2f257

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

script/core/hover/init.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,9 @@ local function getHover(source, level)
5959

6060
-- make sure `function` is before `doc.type.function`
6161
local orders = {'function', 'doc.type.function'}
62+
local orderAnyOtherType = #orders + 1
6263
table.sort(defs, function (a, b)
63-
return (orders[a.type] or (#orders + 1)) < (orders[b.type] or (#orders + 1))
64+
return (orders[a.type] or orderAnyOtherType) < (orders[b.type] or orderAnyOtherType)
6465
end)
6566

6667
local hasFunc

0 commit comments

Comments
 (0)