Page 1 of 1

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

Posted: Fri Sep 11, 2026 8:21 pm
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

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

Posted: Tue Sep 15, 2026 11:49 am
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).