Skip to content

Commit

Permalink
Don't get meta table if we don't need to check it
Browse files Browse the repository at this point in the history
  • Loading branch information
lL1l1 committed Dec 22, 2024
1 parent 584e5ba commit 106837b
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions lua/system/repr.lua
Original file line number Diff line number Diff line change
Expand Up @@ -343,9 +343,14 @@ function Inspector:putValue(v)
end
end

local mt = getmetatable(t)
local checkMetaTable = self.meta and type(mt) == 'table' and not TableEmpty(mt)
if checkMetaTable then
local mt
local checkMeta
if self.meta then
mt = getmetatable(t)
checkMeta = type(mt) == 'table' and not TableEmpty(mt)
end

if checkMeta then
if seqLen + keysLen > 0 then puts(buf, ',') end
tabify(self)
puts(buf, '<metatable> = ')
Expand All @@ -354,7 +359,7 @@ function Inspector:putValue(v)

self.level = self.level - 1

if keysLen > 0 or checkMetaTable then
if keysLen > 0 or checkMeta then
tabify(self)
elseif seqLen > 0 then
puts(buf, ' ')
Expand Down

0 comments on commit 106837b

Please sign in to comment.