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

Use Long.parseLong(CharSequence,int,int,int) to avoid intermediate String creation #30710

Closed
wants to merge 1 commit into from

Conversation

kilink
Copy link
Contributor

@kilink kilink commented Jun 21, 2023

Where possible, switch to the Long.parseLong variant that accepts a start and end index for the supplied CharSequence, thus avoiding making an unnecessary copy of the input.

Where possible, switch to the Long.parseLong variant that accepts a start and end index for the supplied CharSequence,
thus avoiding making an unncessary copy of the input.
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Jun 21, 2023
@sbrannen sbrannen changed the title Avoid copying when parsing Longs in a few places Use Long.parseLong(CharSequence,int,int,int) to avoid intermediate String creation Jul 15, 2023
@sbrannen
Copy link
Member

@kilink, thanks for the PR.

Have you experienced any performance issues which inspired you to make the proposed changes?

@sbrannen sbrannen added status: waiting-for-feedback We need additional information before we can continue in: web Issues in web modules (web, webmvc, webflux, websocket) type: task A general task in: core Issues in core modules (aop, beans, core, context, expression) labels Jul 15, 2023
@kilink
Copy link
Contributor Author

kilink commented Jul 17, 2023

@kilink, thanks for the PR.

Have you experienced any performance issues which inspired you to make the proposed changes?

I did not observe any issue in particular, but I had noticed that the Integer.parseInteger variant that takes start / end indices is being used throughout the codebase, and it seemed like the same optimization hadn't been applied for instances of Long.parseLong where it is possible to avoid creating a substring.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Jul 17, 2023
@sbrannen sbrannen added this to the 6.1.0-M4 milestone Jul 19, 2023
@sbrannen
Copy link
Member

I did not observe any issue in particular, but I had noticed that the Integer.parseInteger variant that takes start / end indices is being used throughout the codebase, and it seemed like the same optimization hadn't been applied for instances of Long.parseLong where it is possible to avoid creating a substring.

Thanks for the feedback.

Indeed, we made that change for Integer.parseInt in conjunction with #27680.

In light of that, I'll schedule this improvement for 6.1 M4.

@sbrannen sbrannen self-assigned this Jul 19, 2023
@sbrannen sbrannen added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged or decided on status: feedback-provided Feedback has been provided type: task A general task labels Jul 19, 2023
sbrannen added a commit to sbrannen/spring-framework that referenced this pull request Aug 1, 2023
@sbrannen sbrannen closed this in 01e90bb Aug 1, 2023
@sbrannen
Copy link
Member

sbrannen commented Aug 1, 2023

This has been merged into main.

Thanks

@kilink kilink deleted the long-parse-without-copy branch March 15, 2024 19:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants