Commit cae2d8d
Alec Gibson
Improve performance of
Running `getOps` to fetch a large number of operations is not very
performant.
Anecdotally, performing this operation on a local development machine
with a document comprising of ~200,000 operations takes ~20s.
The largest slow-down appears to come from the `getLinkedOps` method,
and in particular the use of `Array.unshift`.
This change "inverts" the logic of the `getLinkedOps` function. Rather
than building up an array from scratch, instead we create a shallow copy
of the `ops` array using `slice`, and remove any operations we don't
want using `splice`.
The anecdotal operation time using this modified function is now ~2s,
which is an improvement of an order of magnitude. The performance when
fetching a small number of operations is similar.getLinkedOps
1 parent 5a7c674 commit cae2d8d
1 file changed
+9
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
526 | 526 | | |
527 | 527 | | |
528 | 528 | | |
529 | | - | |
| 529 | + | |
| 530 | + | |
530 | 531 | | |
531 | 532 | | |
532 | | - | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
533 | 538 | | |
534 | 539 | | |
535 | 540 | | |
536 | 541 | | |
537 | | - | |
| 542 | + | |
| 543 | + | |
538 | 544 | | |
539 | 545 | | |
540 | 546 | | |
| |||
0 commit comments