Skip to content

Commit

Permalink
Faster resets.
Browse files Browse the repository at this point in the history
  • Loading branch information
Hekili committed Jan 25, 2024
1 parent 7cf1145 commit 64a5562
Showing 1 changed file with 9 additions and 20 deletions.
29 changes: 9 additions & 20 deletions Utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1013,16 +1013,9 @@ do

local seen = {}

function ns.Mark( table, key )
local unique = tostring( table ) .. ":" .. tostring( key )

if not seen[ unique ] then
local data = remove( pool ) or {}
data.t = table
data.k = key
insert( marked, data )
seen[ unique ] = true
end
function ns.Mark( t, key )
if not marked[ t ] then marked[ t ] = {} end
marked[ t ][ key ] = true
end

function ns.SuperMark( table, keys )
Expand All @@ -1049,20 +1042,16 @@ do

wipe( seen )
else
local data = remove( marked )
while( data ) do
local unique = tostring( data.t ) .. ":" .. tostring( data.k )

if seen[ unique ] then
rawset( data.t, data.k, nil )
insert( pool, data )
seen[ unique ] = nil
for t, data in pairs( marked ) do
for key in pairs( data ) do
rawset( t, key, nil )
data[ key ] = nil

count = count + 1
end

data = remove( marked )
end
end

local endTime = debugprofilestop()
if Hekili.ActiveDebug then Hekili:Debug( "Purged %d marked values in %.2fms.", count, endTime - startTime ) end
end
Expand Down

0 comments on commit 64a5562

Please sign in to comment.