[BUGFIX] Chart Editor - Fix duplicating selection boxes (fix fastIndexOf implementation)#5073
Conversation
|
Fixes #4277 |
I cannot reproduce that one even on a 0.5.3 build so maybe not. |
65d2ae9 to
481ad86
Compare
fastIndexOf implementation)
481ad86 to
52bf3ae
Compare
oh... |
|
Aight I think it fixes all of my #5064 issues it seems, thanks 👍 |
52bf3ae to
08f6a9c
Compare
I'm pretty sure that's not how time complexity works, but it seems like it'll work fine regardless. |
You're most certainly right lol. But the point I wanted to get across is that it comes with a cost, even though it's probably negligible unless we're considering a chart completely filled with notes of equal time (or so I believe would be a worst case scenario) |
|
Note to self: reproduction of this issue requires moving the note to a row which has another note in a different column, it doesn't happen when there's a lone note. |
Linked Issues
Closes #5064
Description
The chart editor uses an array,
displayedNoteDatato dictate whether a rendered note sprite should be created, kept or killed, which would be populated with duplicate notes or be missing notes, which was caused byfastIndexOfnot working very well with notes of same time. This would cause multiple selection boxes and apparently multiple note sprites being unnecessarily created, seemingly causing a space leak.To fix this I had to modify
SongNoteDataArrayTools.fastIndexOf, it was either this or replacing the functions withcontains. This changes the time complexity fromO(log n)to a worst case ofan extraO(log n) + O(k + l)O(k)andO(l)wherekis the number of notes sharing the same time towards the left - andltowards the right - ofmidIndex.The issue with the original implementation is that if notes are never equal but have the same time,
highIndexwill keep decreasing until the search stops and never finds the note, even if it actually exists in the array. So I've made it so it does extra checking towards both "directions" of the array while there's notes of equal time.I've profiled the function via Tracy and saw no noticeable difference in performance, in fact it might even save some since rendered notes are now properly killed only when they need to.
Screenshots/Videos
8mb.video-hKB-PZkjhpz4.mp4