Skip to content
Permalink
Browse files
[Truffle] - String#downcase! returning nil if no changes were made.
  • Loading branch information
lucasallan committed Dec 22, 2014
1 parent 2851935 commit 827f20a3c8313b2934143879f5ec7b3ddb2507f6
Showing with 10 additions and 3 deletions.
  1. +10 −3 core/src/main/java/org/jruby/truffle/nodes/core/StringNodes.java
@@ -457,11 +457,18 @@ public DowncaseBangNode(DowncaseBangNode prev) {
}

@Specialization
public RubyString downcase(RubyString string) {
public RubyBasicObject downcase(RubyString string) {
notDesignedForCompilation();

string.set(ByteList.create(string.toString().toLowerCase()));
return string;
ByteList newByteList = ByteList.create(string.toString().toLowerCase());
newByteList.setEncoding(string.getBytes().getEncoding());

if (newByteList.equals(string.getBytes())) {
return getContext().getCoreLibrary().getNilObject();
} else {
string.set(newByteList);
return string;
}
}
}

0 comments on commit 827f20a

Please sign in to comment.