Skip to content

Commit

Permalink
Change variable names
Browse files Browse the repository at this point in the history
  • Loading branch information
Ukendio committed Jul 28, 2024
1 parent 7f2d6a9 commit b79bbb5
Showing 1 changed file with 23 additions and 22 deletions.
45 changes: 23 additions & 22 deletions test/tests.luau
Original file line number Diff line number Diff line change
Expand Up @@ -579,9 +579,8 @@ do
local world
local T
local PreviousT
local addedComponents
local removedComponents
local isTrivial
local add
local is_trivial
local added
local removed

Expand All @@ -594,26 +593,36 @@ do
return nil
end

if isTrivial == nil then
if is_trivial == nil then
isTrivial = typeof(data) ~= "table"
end

if not isTrivial then
data = table.clone(data)
end

addedComponents[id] = data
add[id] = data
return id, data
end
end

local function shallowEq(a, b)
local function diff(a, b)
local size = 0
for k, v in a do
if b[k] ~= v then
return false
return true
end
size += 1
end
return true
for k, v in b do
size -= 1
end

if size ~= 0 then
return true
end

return false
end

local function changes_changed()
Expand All @@ -626,18 +635,15 @@ do
return nil
end

if not isTrivial then
if not shallowEq(new, old) then
break
end
elseif new ~= old then
if isTrivial and new ~= old then
elseif diff(new, old) then
break
end

id, new, old = q:next()
end

addedComponents[id] = new
add[id] = new

return id, old, new
end
Expand All @@ -650,7 +656,7 @@ do
return function()
local id = q:next()
if id then
table.insert(removedComponents, id)
world:remove(id, PreviousT)
end
return id
end
Expand Down Expand Up @@ -678,13 +684,9 @@ do
end
end

for e, data in addedComponents do
for e, data in add do
world:set(e, PreviousT, if isTrivial then data else table.clone(data))
end

for _, e in removedComponents do
world:remove(e, PreviousT)
end
end

local tracker = { track = track }
Expand All @@ -694,8 +696,7 @@ do
T = component
-- We just use jecs.Rest because people will probably not use it anyways
PreviousT = jecs.pair(jecs.Rest, T)
addedComponents = {}
removedComponents = {}
add = {}

return tracker
end
Expand Down

0 comments on commit b79bbb5

Please sign in to comment.