Skip to content

Conversation

@kilink
Copy link
Contributor

@kilink kilink commented Nov 2, 2025

Use the Integer.parseInt variant added in Java 9 that allows parsing of numbers from a String with offsets, avoiding the need to create any substrings.

Use the Integer.parseInt variant added in Java 9 that allows parsing of numbers from a String
with offsets, avoiding the need to create any substrings.
@kilink kilink force-pushed the unicode-util-hex-parsing branch from c33bece to 91fa11f Compare November 2, 2025 21:37
@andimarek
Copy link
Member

andimarek commented Nov 2, 2025

@kilink how did you find this improvement? profiler or some static code analysis? something else?

@bbakerman bbakerman added this to the 25.x breaking changes milestone Nov 2, 2025
@bbakerman
Copy link
Member

The performance will be the removal of the subsrtring iteration and memory allocation

java.lang.Integer#parseInt(java.lang.CharSequence, int, int, int) iterates the string via s.charAt(i) and hence does not allocate any temp strings

Copy link
Member

@bbakerman bbakerman left a comment

Choose a reason for hiding this comment

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

Thanks

@bbakerman bbakerman merged commit 7afaeef into graphql-java:master Nov 2, 2025
4 checks passed
@kilink kilink deleted the unicode-util-hex-parsing branch November 3, 2025 02:00
@kilink
Copy link
Contributor Author

kilink commented Nov 3, 2025

@kilink how did you find this improvement? profiler or some static code analysis? something else?

A combination of flame graphs from services, and just reading lots of code and seeing patterns. For instance, I'm not sure when exactly graphql-java started targeting JDK 11, but whenever we move the baseline up I see it as an opportunity to leverage new APIs that are either more efficient or more concise. Some of this is just proactive and something I enjoy contributing.

@andimarek
Copy link
Member

@kilink how did you find this improvement? profiler or some static code analysis? something else?

A combination of flame graphs from services, and just reading lots of code and seeing patterns. For instance, I'm not sure when exactly graphql-java started targeting JDK 11, but whenever we move the baseline up I see it as an opportunity to leverage new APIs that are either more efficient or more concise. Some of this is just proactive and something I enjoy contributing.

Thanks for contributing!

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.

3 participants