perf(parser): pre-allocate extends vec with 1 cap#20667
perf(parser): pre-allocate extends vec with 1 cap#20667graphite-app[bot] merged 1 commit intomainfrom
extends vec with 1 cap#20667Conversation
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. |
There was a problem hiding this comment.
Pull request overview
This PR makes a small parser performance tweak by pre-allocating the extends list with capacity 1 in class heritage parsing, avoiding an initial grow on the common single-extends case.
Changes:
- Pre-allocate the
extendsvector inparse_extends_clauseusingvec_with_capacity(1)instead ofvec().
Merging this PR will not alter performance
Comparing Footnotes
|
Merge activity
|
if we hit here, it means that we've seen the `extends` keyword - having code like `class foo extends {}` is invalid as there must be at least one extends expression, so min size of the `extends`vec will be 1.
This just avoids the re-alloc
2cb0cb3 to
ad58dd7
Compare
4172d22 to
611fca5
Compare

if we hit here, it means that we've seen the
extendskeyword - having code likeclass foo extends {}is invalid as there must be at least one extends expression, so min size of theextendsvec will be 1.This just avoids the re-alloc