Hi!
Love your mod, but not a huge fan of the UPS impact it has on my 100-train base. So I ran it through jarg's profiler and found that the main issue could be solved with a bit of caching. Currently, each time a train changes state, you're checking the active mod list against a table of ~80 mods to see if any item names need to be adjusted (and then repeating this for each unique item on the train). Thing is, that active mod list isn't ever going to change except during startup, so you're better off caching it and adjusting it only when needed.
I went ahead and implemented a fix on my local copy of the mod--here's what I did:
In control.lua, I added the following:
local function cache_mods()
global.mods = {}
for mod, t in pairs(mod_list) do
if script.active_mods[mod] then
global.mods[mod] = t
end
end
end
script.on_init(cache_mods)
script.on_configuration_changed(cache_mods)
I also changed the line for LTN check to:
if global.mods["LogisticTrainNetwork"] then
In color/util.lua, I replaced lines 10 and 11 with:
for mod, filterlist in pairs(global.mods) do
if filterlist[3] ~=nil then
There were a few other places that might benefit from some caching, but honestly they're pretty irrelevant when compared to this. I tested this new code on my big train base. Before the changes, I was seeing ~0.6 ms per average update, and after, I saw ~0.05 ms per average update.
I hope you consider making those changes!