amethyst / sheep

Modular and lightweight spritesheet packer 🐑
Other
89 stars 12 forks source link

O(n^2) complexity in sprite/anchor matching #15

Closed basil-cow closed 5 years ago

basil-cow commented 5 years ago

When finding an anchor corresponding to a sprite in pack(), program iterates over all anchors for each sprite. I assume that it's for maintaining sprite order (but they could be still in different sheets, right? so why does it matter if they are sorted?). O(n^2) can be reduced to O(n) with a hashmap of anchors, but maybe I'm missing some context why it was done the way it is.

happenslol commented 5 years ago

Nope, that's definitely just an easy optimization that can be done. I wrote that code once and never looked at it again, must've just missed that =P Would be happy about a PR here!

basil-cow commented 5 years ago

this can now be closed with #22 merging

happenslol commented 5 years ago

Will close when #22 is through.