mirror of
https://codeberg.org/adnano/wmenu.git
synced 2025-10-29 05:40:20 -04:00
Optimize menu sorting
Sorting and deduplicating elements after all items have been registered improves the time complexity of constructing the item list from O(n^2) to O(n log n). On a system with about 4000 menu items, this reduces startup time from about 0.21 seconds to 0.13 seconds.
This commit is contained in:
parent
12b8f83be4
commit
260eaba88e
5 changed files with 50 additions and 42 deletions
|
|
@ -20,10 +20,11 @@ static void read_items(struct menu *menu) {
|
|||
if (ent->d_name[0] == '.') {
|
||||
continue;
|
||||
}
|
||||
menu_add_item(menu, strdup(ent->d_name), true);
|
||||
menu_add_item(menu, strdup(ent->d_name));
|
||||
}
|
||||
closedir(dir);
|
||||
}
|
||||
menu_sort_and_deduplicate(menu);
|
||||
free(path);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue