perf(allocator): remove op from StringBuilder::grow_one#20650
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
Merging this PR will not alter performance
Comparing Footnotes
|
There was a problem hiding this comment.
Pull request overview
This PR optimizes oxc_allocator’s StringBuilder growth path by removing a redundant overflow check in StringBuilder::grow_one, which is on the hot path for single-byte pushes (e.g. push_ascii_byte).
Changes:
- Replaced
checked_add(...).expect(...)with a directcurrent_capacity + additionalinStringBuilder::grow_one. - Added an explanatory comment documenting why
usizeoverflow cannot occur for this addition under the existing capacity invariants.
Merge activity
|
Remove a bounds check from `StringBuilder::grow_one` (which is used by `StringBuilder::push_ascii_byte`). Rationale is explained in comment added in this PR.
b8470d3 to
89a5374
Compare

Remove a bounds check from
StringBuilder::grow_one(which is used byStringBuilder::push_ascii_byte). Rationale is explained in comment added in this PR.