screeps / engine

ISC License
134 stars 66 forks source link

[Optimization] processor/roads/tick #127

Open Mysak0CZ opened 4 years ago

Mysak0CZ commented 4 years ago

Why does road during decay iterates 2 times through all room objects searching for objects of type "swamp" and "wall". Shouldn't it be enough to just check the terrain mask? https://github.com/screeps/engine/blob/fe8fb54a7f6ced26ed8283cc69877da75c2a5bd7/src/processor/intents/roads/tick.js#L12 https://github.com/screeps/engine/blob/fe8fb54a7f6ced26ed8283cc69877da75c2a5bd7/src/processor/intents/roads/tick.js#L16 Removing the _.any(...) check would change complexity from O(n) to O(1). I don't have any server to check impacts of this optimizations.

o4kapuk commented 4 years ago

This change is potentially breaking for terrain editing in simulation, need to rework this feature before removing those _.any() checks