Commit 35bc0b4
committed
perf: sort discovered sync items once instead of inserting in order
slotItemDiscovered() kept _syncItems sorted by inserting each item at its
lower_bound. Inserting into the middle of a contiguous vector memmoves the tail,
so discovering n items costs O(n^2): for a first sync of a large tree that is
billions of shared-pointer moves on the GUI thread, all of it before the first
file is transferred.
Nothing reads _syncItems before discovery ends -- the first consumer is
handleMassDeletion(), from slotDiscoveryFinished() -- so append and sort once
there. Stable, so that items comparing equal keep the order they were
discovered in.
Signed-off-by: Felipe Tumonis <ftumonis@gmail.com>1 parent 68778d6 commit 35bc0b4
1 file changed
Lines changed: 9 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
| |||
473 | 474 | | |
474 | 475 | | |
475 | 476 | | |
476 | | - | |
477 | | - | |
478 | | - | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
479 | 481 | | |
480 | 482 | | |
481 | 483 | | |
| |||
847 | 849 | | |
848 | 850 | | |
849 | 851 | | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
850 | 856 | | |
851 | 857 | | |
852 | 858 | | |
| |||
0 commit comments