Commit 5ccab84
committed
perf: cache sorted visible key names on Val.Obj
Motivation:
Non-inline objects (>8 fields, super chains, excludedKeys) call
.sorted(CodepointStringOrdering) on visibleKeyNames at every
materialization. This re-sorts and allocates a new array each time.
Modification:
Add _sortedVisibleKeyNames cache on Val.Obj with lazy initialization.
Replace all 5 call sites (Materializer recursive/stackless, Renderer,
ByteRenderer, Val.Obj.foreachElement) with the cached accessor.
Result:
Objects with stable schemas sort their key names once and reuse the
result on subsequent materializations.1 parent b63fb40 commit 5ccab84
3 files changed
Lines changed: 16 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
391 | 391 | | |
392 | 392 | | |
393 | 393 | | |
394 | | - | |
| 394 | + | |
395 | 395 | | |
396 | 396 | | |
397 | 397 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
103 | | - | |
| 103 | + | |
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
| |||
432 | 432 | | |
433 | 433 | | |
434 | 434 | | |
435 | | - | |
| 435 | + | |
436 | 436 | | |
437 | 437 | | |
438 | 438 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
884 | 884 | | |
885 | 885 | | |
886 | 886 | | |
887 | | - | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
888 | 899 | | |
889 | 900 | | |
890 | 901 | | |
| |||
1402 | 1413 | | |
1403 | 1414 | | |
1404 | 1415 | | |
1405 | | - | |
| 1416 | + | |
1406 | 1417 | | |
1407 | 1418 | | |
1408 | 1419 | | |
| |||
0 commit comments