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

Avoid unnecessary char[] allocation in NamedParameterUtils [SPR-11042] #15670

Closed
spring-issuemaster opened this issue Oct 29, 2013 · 4 comments
Assignees
Milestone

Comments

@spring-issuemaster
Copy link
Collaborator

@spring-issuemaster spring-issuemaster commented Oct 29, 2013

Philippe Marschall opened SPR-11042 and commented

Overview

NamedParameterUtils.substituteNamedParameters() uses the following pattern:

stringBuilder.append(str.substring(start, end));

This wasn’t such an issue in HotSpot up to Java 7 Update 6, because even though it would allocate an unnecessary String, it would not allocate a new char[]. This all changed with 7u6 when String#substring started allocating a new char[] (it always did on J9).

Proposed Solution

Luckily this can easily be solved with the following pattern:

stringBuilder.append(str, start, end);

Affects: 3.2.4

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Oct 29, 2013

Philippe Marschall commented

Pull request here:
#397

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Nov 1, 2013

Juergen Hoeller commented

Fixed for 4.0 RC2 and backported to 3.2.5 now.

Juergen

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Nov 3, 2013

Philippe Marschall commented

The pull request is still open but the issue marked as resolved. Should I close the pull request or are you going to merge it?

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Nov 3, 2013

Sam Brannen commented

I just closed the pull request.

Thanks for the contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.