Skip to content

Commit

Permalink
simplify the __gc check
Browse files Browse the repository at this point in the history
  • Loading branch information
Tieske committed Jun 20, 2024
1 parent 906044c commit 2d636f5
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions system/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,8 @@ do -- autotermrestore


local add_gc_method do
-- feature detection; __GC meta-method, not available in all Lua versions
local has_gc = false
local tt = setmetatable({}, { -- luacheck: ignore
__gc = function() has_gc = true end
})

-- clear table and run GC to trigger
tt = nil
collectgarbage()
collectgarbage()

-- __gc meta-method is not available in all Lua versions
local has_gc = not newproxy or false -- `__gc` was added when `newproxy` was removed

if has_gc then
-- use default GC mechanism since it is available
Expand Down

0 comments on commit 2d636f5

Please sign in to comment.