Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(handlers): optimize string-buffer reallocations #387

Merged
merged 1 commit into from
Jun 26, 2024

Conversation

lucab
Copy link
Contributor

@lucab lucab commented Jun 26, 2024

This improves get_lines() logic by using a string-buffer with a capacity hint. That avoids growing the buffer from zero each time, saving a bunch of reallocations.

This is a forwarded patch from oxc-project/oxc#3897, see there for further explanations and datapoints.

This improves `get_lines()` logic by using a string-buffer with a capacity hint.
That avoids growing the buffer from zero each time, saving a bunch of reallocations.
Copy link
Owner

@zkat zkat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh hey cool, thanks! I generally didn't spend a lot of time worrying about optimization of the handlers because I figured it wasn't a big deal to use a bit more resources there in most cases, but I guess when you're printing a ton of these messages, it's going to show up :)

@zkat zkat merged commit b8dfcda into zkat:main Jun 26, 2024
2 of 15 checks passed
@lucab lucab deleted the ups/avoid-reallocs branch June 27, 2024 09:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants