Reduce overhead of LuaEntity::get_signals with parameter if_modified_since
Posted: Wed Apr 30, 2025 10:32 pm
I'd like to propose the following signature change to LuaEntity::get_signals():
I assume this information is already present somewhere because combinators know when to recalculate, too.
If this is added, there should probably also be a property LuaCircuitNetwork::last_modified : MapTick.
My guess is adding the same to LuaEntity::get_signal() would not be a big improvement. That function already returns an int, only.
Code: Select all
get_signals(wire_connector_id, extra_wire_connector_id?, if_modified_since?) → array[Signal]?, MapTick
With this mods like LTN and Cybersyn that frequently poll signals could greatly reduce Lua garbage overhead and subsequent recalculations for idle circuit networks.Read all signals from the selected wire connector.
Parameters
wire_connector_id :: <as before>
extra_wire_connector_id :: <as before>
if_modified_since :: MapTick? only return fresh signals if they were modified after this tick
Return values
→ array[Signal]? Current values of all signals, nil if there are no signals or if there were no modifications
→ MapTick the tick the signals were last modified, less than or equal to if_modified_since if there were no modifications
I assume this information is already present somewhere because combinators know when to recalculate, too.
If this is added, there should probably also be a property LuaCircuitNetwork::last_modified : MapTick.
My guess is adding the same to LuaEntity::get_signal() would not be a big improvement. That function already returns an int, only.