-
Notifications
You must be signed in to change notification settings - Fork 746
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
Multi-Release jar experiments #4521
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a drive-by comment :)
// We could use buffer.toName(Names), but we want a string anyways and this | ||
// avoids plumbing a Context or instances of Names through. | ||
// Names always uses UTF-8 internally. | ||
return new String(Arrays.copyOf(buffer.elems, buffer.length), UTF_8); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recall once running a benchmark, on the basis of which I concluded that the JVM may be smart enough to conclude that in a scenario such as this one, the String
constructor doesn't need to make a defensive copy of the provided array, as it'll hold the only remaining reference. Still, perhaps it's nicer to instead do:
return new String(Arrays.copyOf(buffer.elems, buffer.length), UTF_8); | |
return new String(buffer.elems, 0, buffer.length, UTF_8); |
(And likewise for the Java 24 variant below.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, good point. I had separately been considering refactoring this to pass through a VisitorState
to these methods instead of Type
, which would allow using buffer.toName(Names)
as the comment here notes. I'll take a look at finishing that.
No description provided.