festival icon indicating copy to clipboard operation
festival copied to clipboard

`Songs` tab is laggy

Open hinto-janai opened this issue 7 months ago • 0 comments

Version

Festival GUI v1.3.0

Bug

The Songs tab is very laggy.

Although the current code only displays the viewport (good), every single Song object is iterated through and processed (very bad).

Fix

Selectively index through the songs (e.g [start..end]) and only process and display those.

The issue is when a scrollbar is involved - "where" we are in the array must be accounted for depending on how far the scrollbar has scrolled.

The range (e.g 10 songs listed? 20 songs?) depends on sizing, resolution, etc - although this should be easy to find:

let total_rows = ui.height() / desired_row_height;

for song in songs[start..start + total_rows] {
    /* process and display songs */
}

Different sort orderings may change things as well.

hinto-janai avatar Nov 13 '23 19:11 hinto-janai