LuaTransportLine.get_detailed_contents() last item position without table allocation(s)

sparr
Smart Inserter
Smart Inserter
Posts: 1564
Joined: Fri Feb 14, 2014 5:52 pm
Contact:

LuaTransportLine.get_detailed_contents() last item position without table allocation(s)

Post by sparr »

Table allocation and garbage collection from repeated transport line inspections is the biggest performance hit in my attempt to update/improve https://mods.factorio.com/mod/belt-overflow/downloads

What I need is just the position of the last item on the line. Right now to get that I have to call get_detailed_contents which returns the whole array[DetailedItemOnLine], with a flood of information I don't want or need.

Proposals:
get_detailed_contents(uint) returns just one DetailedItemOnLine
get_contents_positions() returns array[float], omiting the (item)stack and unique_id for each item
detailed_contents as an array proxy that supports # and [], like LuaTransportLine itself does to refer to the array of items without position or unique_id
User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 4893
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: LuaTransportLine.get_detailed_contents() last item position without table allocation(s)

Post by boskid »

LuaTransportLine::get_item_position() added for 2.1.18. Converts item index (value from 1 up to #len) into linear position and map position (2 return values).
Post Reply

Return to “Implemented mod requests”