-
-
Notifications
You must be signed in to change notification settings - Fork 925
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
[Truffle] Implemented Symbol#upcase, added final in Symbol#swapcase #2621
Conversation
@@ -241,7 +241,28 @@ public SwapcaseNode(SwapcaseNode prev) { | |||
public RubySymbol swapcase(RubySymbol symbol) { | |||
notDesignedForCompilation(); | |||
|
|||
ByteList byteList = StringNodes.StringNodesHelper.swapcase(symbol.toRubyString()); | |||
final ByteList byteList = StringNodes.StringNodesHelper.swapcase(symbol.toRubyString()); |
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.
Converting to a RubyString
isn't ideal - it would be good if we could just use the ByteList
directly. When we are using the JIT compiler the RubyString
wrapper object would not be allocated, but in the interpreter it's a little bit of overhead.
@chrisseaton Thanks for the feedback. I made some fixes. Are there any more updates needed? |
…that are now passing
byteList.set(i, c ^ 0x20); | ||
} | ||
} | ||
return byteList; |
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.
Did you write this from scratch or did it come from the main JRuby code? I'd be surprised if they don't already have a routine we could copy for this.
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.
This was from scratch, Check out this for upcase
public IRubyObject upcase(ThreadContext context) { |
public RubyString upcase19(ThreadContext context) { |
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.
The presence of multiByteUpcase
private IRubyObject multiByteUpcase(Ruby runtime, Encoding enc, byte[]bytes, int s, int end) { |
However, we'll go by the specs for now.
[Truffle] Implemented Symbol#upcase, added final in Symbol#swapcase
Reference String#upcase for implementation