-
Notifications
You must be signed in to change notification settings - Fork 492
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
fix: optimize Range parsing and formatting #726
Conversation
The "refactor:" pull request name prefix was not allowed so I picked "fix:", and changed the commit messages to use the same prefix as well. |
We generally squash-merge external PRs unless there's a compelling reason to keep each commit. linting will pass if either the PR title or every commit has a valid conventional prefix. Don't worry about keeping the commit messages "valid" as we go through this PR, as we'll be using the PR title if and when this lands. |
Thanks for the help in reviewing this @kurtextrem. Yes, that comment was referring to |
Produce fewer intermediate objects when a range's space characters are reduced to single spaces. This appears to have about 5% performance benefit for bench-subset, and smaller but detectable impact on bench-satisfies.
This speeds bench-subset and bench-satisfies by up to 20%.
This speeds bench-subset and bench-satisfies by up to 9%. The external interface of the Range class is kept as-is except that the .range property is not writable anymore. format test
🤖 I have created a release *beep* *boop* --- ## [7.6.3](v7.6.2...v7.6.3) (2024-07-16) ### Bug Fixes * [`73a3d79`](73a3d79) [#726](#726) optimize Range parsing and formatting (#726) (@jviide) ### Documentation * [`2975ece`](2975ece) [#719](#719) fix extra backtick typo (#719) (@stdavis) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This bugfix version of semver includes significant performance improvements that I guess we would like to see in corepack. See: npm/node-semver#726
This pull request optimizes the Range class in the following ways:
.range
string (used by.format()
and.toString()
) lazily. This seems to improve bench-satisfies and bench-subset scores by up to 9%.The external interface for the class stays the same, except for the new internal
.formatted
property used to cache its lazily calculated string.Range#range
property is now also read-only.There is a new test lazy formatting to ensure full test coverage.
The benchmarks bench-satisfies and bench-subset benefit from these changes, sometimes by up to 40%. Other benchmark results seem to stay the same. Here are the affected benchmarks before:
And after: