Skip to content
Permalink
Browse files
[Truffle] - String#clear should preserve the string encoding.
  • Loading branch information
lucasallan committed Dec 22, 2014
1 parent e9444ff commit dbff750bb6cbe100941a654a36b9ba58166acc0e
Showing with 3 additions and 1 deletion.
  1. +3 −1 core/src/main/java/org/jruby/truffle/nodes/core/StringNodes.java
@@ -1264,8 +1264,10 @@ public ClearNode(ClearNode prev) {
@Specialization
public RubyString clear(RubyString string) {
notDesignedForCompilation();
ByteList empty = ByteList.EMPTY_BYTELIST;
empty.setEncoding(string.getBytes().getEncoding());

string.set(ByteList.create(""));
string.set(empty);
return string;
}
}

0 comments on commit dbff750

Please sign in to comment.