Avoid recomputing column size (#100)

This commit is contained in:
Michael 2024-08-12 09:05:40 -04:00 committed by GitHub
parent aa21b5ee47
commit 3de4789c03
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -186,6 +186,7 @@ local function archetype_move(entityIndex: EntityIndex, to: Archetype,
local destinationColumns = to.columns local destinationColumns = to.columns
local records = to.records local records = to.records
local types = from.types local types = from.types
local last = #sourceEntities
for i, column in columns do for i, column in columns do
-- Retrieves the new column index from the source archetype's record from each component -- Retrieves the new column index from the source archetype's record from each component
@ -197,7 +198,6 @@ local function archetype_move(entityIndex: EntityIndex, to: Archetype,
destinationColumns[tr.column][destinationRow] = column[sourceRow] destinationColumns[tr.column][destinationRow] = column[sourceRow]
end end
-- If the entity is the last row in the archetype then swapping it would be meaningless. -- If the entity is the last row in the archetype then swapping it would be meaningless.
local last = #column
if sourceRow ~= last then if sourceRow ~= last then
-- Swap rempves columns to ensure there are no holes in the archetype. -- Swap rempves columns to ensure there are no holes in the archetype.
column[sourceRow] = column[last] column[sourceRow] = column[last]