Commit 731fe95
committed
perf: batch cold-cache pre-warm in mergeCollectionWithPatches via multiGet
Replaces the unconditional Promise.all(existingKeys.map(get)) pre-warm
with a hybrid:
- Fast path (every existingKey is already in cache): use a sync-
resolved Promise — no extra microtask hops, preserving the original
promise-chain depth and subscriber-callback timing that dependent
tests rely on (Onyx.update batch tests broadcast a single merged
callback rather than an `undefined` initial followed by the merged
result).
- Slow path (at least one cache-miss existingKey): use multiGet —
one Storage.multiGet round-trip for the missing keys instead of N
parallel get() invocations.
Net result: same correctness as before, fewer storage operations on
cold-cache merges, identical broadcast timing for warm-cache merges.
Addresses follow-up from Expensify#787 review.1 parent 9445bbf commit 731fe95
1 file changed
Lines changed: 14 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1582 | 1582 | | |
1583 | 1583 | | |
1584 | 1584 | | |
1585 | | - | |
1586 | | - | |
1587 | | - | |
1588 | | - | |
1589 | | - | |
1590 | | - | |
| 1585 | + | |
| 1586 | + | |
| 1587 | + | |
| 1588 | + | |
| 1589 | + | |
| 1590 | + | |
| 1591 | + | |
| 1592 | + | |
| 1593 | + | |
| 1594 | + | |
| 1595 | + | |
| 1596 | + | |
| 1597 | + | |
| 1598 | + | |
1591 | 1599 | | |
1592 | 1600 | | |
1593 | 1601 | | |
| |||
0 commit comments