Skip to content

Commit

Permalink
Optimize query unpacking (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ukendio authored Jan 29, 2024
1 parent 4aa29be commit 6cbbe93
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions lib/World.lua
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,27 @@ function World:query(...)
return
end

if queryLength == 1 then
return entityId, entityData[metatables[1]]
elseif queryLength == 2 then
return entityId, entityData[metatables[1]], entityData[metatables[2]]
elseif queryLength == 3 then
return entityId, entityData[metatables[1]], entityData[metatables[2]], entityData[metatables[3]]
elseif queryLength == 4 then
return entityId,
entityData[metatables[1]],
entityData[metatables[2]],
entityData[metatables[3]],
entityData[metatables[4]]
elseif queryLength == 5 then
return entityId,
entityData[metatables[1]],
entityData[metatables[2]],
entityData[metatables[3]],
entityData[metatables[4]],
entityData[metatables[5]]
end

for i, metatable in ipairs(metatables) do
queryOutput[i] = entityData[metatable]
end
Expand Down

0 comments on commit 6cbbe93

Please sign in to comment.