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