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
base: ruby-2.3
from

Conversation

Projects
None yet
2 participants
@cheald
Contributor

cheald commented Dec 12, 2015

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

[ruby-2.3 Feature #11785] add `encoding:` optional argument to `Strin…
…g.new`

Adds kwargs support to String#initialize such that it will accept an optional :encoding argument.
Move the initialize keywords out of the function so they aren't alloc…
…ated per invocation. Slightly less typechecking; now behaves similarly to ruby-head when passed invalid types for arg0.
@kares

This comment has been minimized.

Show comment
Hide comment
@kares

kares Dec 13, 2015

believe this was kept for compatibility - so makes no sense to refactor (assuming its not used)

believe this was kept for compatibility - so makes no sense to refactor (assuming its not used)

This comment has been minimized.

Show comment
Hide comment
@cheald

cheald Dec 13, 2015

Owner

I don't know if it was used or not, but it wouldn't compile without the change. :)

Owner

cheald replied Dec 13, 2015

I don't know if it was used or not, but it wouldn't compile without the change. :)

This comment has been minimized.

Show comment
Hide comment
@kares

kares Dec 13, 2015

there are other ways to fix it than changing a public signature ... new IRubyObject[] { arg0 } bellow

kares replied Dec 13, 2015

there are other ways to fix it than changing a public signature ... new IRubyObject[] { arg0 } bellow

@kares

This comment has been minimized.

Show comment
Hide comment
@kares

kares Dec 13, 2015

what about having (arg0) version with a (arg0, arg1) so its mostly one method call for the (arg0) case

what about having (arg0) version with a (arg0, arg1) so its mostly one method call for the (arg0) case

This comment has been minimized.

Show comment
Hide comment
@cheald

cheald Dec 13, 2015

Owner

Is the idea that we want to avoid the extra work when arg1 isn't passed? We'd still need to check if it's a hash or string; String.new(encoding: "utf-8") is valid.

Owner

cheald replied Dec 13, 2015

Is the idea that we want to avoid the extra work when arg1 isn't passed? We'd still need to check if it's a hash or string; String.new(encoding: "utf-8") is valid.

This comment has been minimized.

Show comment
Hide comment
@kares

kares Dec 13, 2015

aaah - in that case its probably fine as it is ... thought it always gets the first arg0 with encoding:

kares replied Dec 13, 2015

aaah - in that case its probably fine as it is ... thought it always gets the first arg0 with encoding:

@kares

This comment has been minimized.

Show comment
Hide comment
@kares

kares Dec 13, 2015

should be static

should be static

@kares

This comment has been minimized.

Show comment
Hide comment
@kares

kares Dec 13, 2015

Member

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

Member

kares commented Dec 13, 2015

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

@kares kares closed this Dec 13, 2015

@kares kares added this to the JRuby 9.1.0.0 milestone Dec 13, 2015

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