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

[ruby-2.3 Feature #11785] add encoding: optional argument to String.new #3535

Closed
wants to merge 3 commits into from

Conversation

cheald
Copy link
Contributor

@cheald cheald commented Dec 12, 2015

Adds kwargs support to String#initialize such that it will accept an optional :encoding argument.

…g.new`

Adds kwargs support to String#initialize such that it will accept an optional :encoding argument.
replace19(arg0);
@JRubyMethod(name = "initialize", visibility = PRIVATE, optional = 2)
public IRubyObject initialize19(ThreadContext context, IRubyObject[] args) {
final String[] validArgs = new String[]{"encoding"};
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not quite sure what Java will do here - since it's a final String[], will it be optimized away, or is this going to result in an allocation per invocation? Should this be moved to an array initialized outside of the method?

…ated per invocation. Slightly less typechecking; now behaves similarly to ruby-head when passed invalid types for arg0.
@kares
Copy link
Member

kares commented Dec 13, 2015

picked onto ruby-2.3 with some tunings and maintained initialize compatibility: a3c648d ... thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants