Commit 98a7831
authored
enhance(normalizr): Avoid hidden class mutation in normalize() result (#3878)
The normalize() return object was constructed with result: '' as any,
then mutated via ret.result = visit(...). This causes a V8 hidden class
transition when the property type changes from string to the actual
result type (array/object/string), triggering "field type constness
changed" invalidations that deoptimize code depending on this object
shape.
Restructured to compute the result first and construct the final
NormalizedSchema in a single step, keeping the object shape stable from
creation.
Made-with: Cursor1 parent e9e96f1 commit 98a7831
2 files changed
Lines changed: 15 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
82 | | - | |
83 | | - | |
| 82 | + | |
84 | 83 | | |
85 | 84 | | |
86 | 85 | | |
87 | 86 | | |
88 | | - | |
89 | | - | |
90 | | - | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
91 | 94 | | |
92 | 95 | | |
93 | 96 | | |
| |||
0 commit comments