Commit d1571ac
committed
refactor: Optimize list sorting and indexing logic
This commit refactors the list processing logic to improve its efficiency and safety.
Previously, sorting involved multiple index lookups (`list.indexOf(it)`) within the comparator, which was inefficient. The new implementation pre-calculates the pinned status of each item and stores it in a `pinnedStatusMap`. This map is then used during the sorting process, eliminating the need for repeated index lookups.
Additionally, building the scroll index has been made safer by using the `pinnedStatusMap` instead of relying on `items.getOrNull(index)`, avoiding potential mismatches.
The comments in the code have also been updated to reflect these changes.1 parent c823cd1 commit d1571ac
File tree
1 file changed
+9
-6
lines changed- app/src/main/java/com/github/droidworksstudio/mlauncher
1 file changed
+9
-6
lines changedLines changed: 9 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
463 | 463 | | |
464 | 464 | | |
465 | 465 | | |
466 | | - | |
| 466 | + | |
467 | 467 | | |
468 | 468 | | |
469 | 469 | | |
470 | 470 | | |
471 | 471 | | |
472 | 472 | | |
473 | 473 | | |
474 | | - | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
475 | 478 | | |
476 | | - | |
| 479 | + | |
477 | 480 | | |
478 | | - | |
| 481 | + | |
479 | 482 | | |
480 | 483 | | |
481 | 484 | | |
482 | | - | |
| 485 | + | |
483 | 486 | | |
484 | 487 | | |
485 | | - | |
| 488 | + | |
486 | 489 | | |
487 | 490 | | |
488 | 491 | | |
| |||
0 commit comments