Speeding up the stockpile item count.

kr0pper reports two orders of magnitude speed improvement for check_pile() by using the map tile item cache.
develop
Eric Wald 2014-08-23 17:49:03 -06:00
parent 8495bddc2d
commit 632b0b85bd
1 changed files with 4 additions and 4 deletions

@ -978,10 +978,10 @@ end
function findItemsAtTile(x, y, z) function findItemsAtTile(x, y, z)
-- There should be a faster and easier way to do this... -- There should be a faster and easier way to do this...
local found = {} local found = {}
for _, item in ipairs(df.global.world.items.all) do local items = dfhack.maps.getTileBlock(x, y, z).items
-- local ix, iy, iz = dfhack.items.getPosition(item) for _, item_id in ipairs(items) do
if item.pos.x == x and item.pos.y == y and local item = df.item.find(item_id)
item.pos.z == z and item.flags.on_ground then if item.pos.x == x and item.pos.y == y and item.flags.on_ground then
found[#found+1] = item found[#found+1] = item
end end
end end