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

Reduce allocations and batch appends on StringUtil::replaceNonAlphanumericByUnderscores #1133

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

franz1981
Copy link
Contributor

@radcortez this is still a draft, but it:

  • avoid allocating at all any StringBuilder if not necessary (usually it happens)
  • it avoid advancing the StringBuilder 's length for each appended ascii/numeric char (including performing bound checks over and over), but try hard performing an optimized batch append

I have to write a JMH bench to verify if it is much better (as I expect, given that while still C1 compiled, usually, having less work overall deliver better performance) or instead is better to split the state machine into different loops (not on this PR yet).

I'll provide a JMH benchmark to show if it brings the benefits I expect

@franz1981
Copy link
Contributor Author

As usual, humans sucks at estimation :P
JMH reveal something interesting, when the code is interpreted; will update soon this draft

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.

1 participant