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

[Truffle] Implemented Symbol#upcase, added final in Symbol#swapcase #2621

Merged
merged 3 commits into from Feb 26, 2015

Conversation

bjfish
Copy link
Contributor

@bjfish bjfish commented Feb 25, 2015

Reference String#upcase for implementation

@@ -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());
Copy link
Contributor

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.

@bjfish
Copy link
Contributor Author

bjfish commented Feb 25, 2015

@chrisseaton Thanks for the feedback. I made some fixes. Are there any more updates needed?

byteList.set(i, c ^ 0x20);
}
}
return byteList;
Copy link
Contributor

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.

Copy link
Contributor Author

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) {

Copy link
Contributor

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) {
makes me think there might be some edge cases we aren't covering here.

However, we'll go by the specs for now.

chrisseaton added a commit that referenced this pull request Feb 26, 2015
[Truffle] Implemented Symbol#upcase, added final in Symbol#swapcase
@chrisseaton chrisseaton merged commit 5077169 into jruby:master Feb 26, 2015
@chrisseaton chrisseaton modified the milestone: truffle-dev May 4, 2015
@enebo enebo added this to the Non-Release milestone Dec 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants