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

@chrisseaton chrisseaton Feb 25, 2015

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

@chrisseaton chrisseaton Feb 26, 2015

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

@bjfish bjfish Feb 26, 2015

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

@chrisseaton chrisseaton Feb 26, 2015

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 issue Feb 26, 2015
[Truffle] Implemented Symbol#upcase, added final in Symbol#swapcase
@chrisseaton chrisseaton merged commit 5077169 into jruby:master Feb 26, 2015
1 check was pending
nirvdrum
Copy link
Contributor

@nirvdrum nirvdrum commented on 37347df Feb 26, 2015

Choose a reason for hiding this comment

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

It'd be great to use this implementation for StringNodes, too. Those implementations go through a lot of bad conversions currently. Since they both operate on ByteLists. it should be fairly trivial (barring any weird encoding issues).

@chrisseaton chrisseaton added this to the truffle-dev milestone May 4, 2015
@chrisseaton chrisseaton added this to the truffle-dev milestone May 4, 2015
@chrisseaton chrisseaton removed this from the truffle-dev milestone May 4, 2015
@chrisseaton chrisseaton removed this from the truffle-dev milestone May 4, 2015
@chrisseaton chrisseaton added this to the truffle-dev milestone May 4, 2015
@chrisseaton chrisseaton added this to the truffle-dev milestone 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