Skip to content

Commit dbff750

Browse files
committed
[Truffle] - String#clear should preserve the string encoding.
1 parent e9444ff commit dbff750

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

core/src/main/java/org/jruby/truffle/nodes/core/StringNodes.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1264,8 +1264,10 @@ public ClearNode(ClearNode prev) {
12641264
@Specialization
12651265
public RubyString clear(RubyString string) {
12661266
notDesignedForCompilation();
1267+
ByteList empty = ByteList.EMPTY_BYTELIST;
1268+
empty.setEncoding(string.getBytes().getEncoding());
12671269

1268-
string.set(ByteList.create(""));
1270+
string.set(empty);
12691271
return string;
12701272
}
12711273
}

0 commit comments

Comments
 (0)