Repository navigation
perf: skip the cycle walk for inserted values that hold no objects, and list own keys in one pass - #74
Merged
Conversation
…nd list own keys in one pass
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The cycle check that runs on every
push,unshift,splice,fill,Object.assignand object element/property write skips its walk when the inserted value is a plain object or array holding no objects or accessors;ownKeyslists keys in one pass instead of three spreads and fourfilters. Behaviour is unchanged: cycles through push, index and property writes are still rejected.Timing, dev 3da1858 vs this PR, under the shared timing lock at load 3.5–4.7 (medians, µs per run):
a.push({ i })a[i] = { i }a.push(i)a = { i }(no insertion)return 1: 160.0 → 161.5 µs (noise);a.push({ i })through Code Mode: 8197 → 2454 µs.bun run check(incl. round-trip) passes; the Code Mode correctness diff over the same corpus is identical (0 of 436 programs changed).