fezhub / DSP-Mods

Dyson Sphere Program Mods
GNU Lesser General Public License v2.1
42 stars 11 forks source link

add memoization to GetPositions method #30

Closed brokenmass closed 3 years ago

brokenmass commented 3 years ago

by additing memoization to GetPositions we can improve performance by over 50 times.

In this specific implementation the memoization strategy is to use a set of 2 'rotating' queues as we can rely on the fact that the inserters are always evaluated in the same order.

If position/rotation of the evaluated building hasn't changed then by definition not even the one of the copied inserter has and we can reuse the result of the previous evaluation.

brokenmass commented 3 years ago

Also fix a compatibility issue with advancedbuilddestruct where sorters are incorrectly tagged as colliding if they intersect another building