EmNudge / Spectrogram-Replicator

Educational Linguistics tool for exploring Spectrograms
https://spectrogram.emnudge.dev
6 stars 2 forks source link

Better Performing Sorting Algorithm #17

Open EmNudge opened 3 years ago

EmNudge commented 3 years ago

When nodes are being moved, we sort all of the nodes on each movement. This allows for lines to properly connect and this is desired behavior.

However, at any given movement we only need to swap the position of 2 nodes. This is in place and should be pretty fast since we know the specific node that needs to move and we can return early if it's still in place.

It isn't clear how great of a performance problem this turns out to be, but it happens often enough that it's a possible bottleneck and an easy optimization.