Skip to content

Commit b3efc76

Browse files
committed
Return EMPTY_US_ASCII for TStringConstants.lookupUSASCIITString("")
* CoreSymbols#NULL uses that, and relies on the TruffleString to be in the TStringCache to avoid duplicates.
1 parent 05b62f3 commit b3efc76

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/main/java/org/truffleruby/core/string/TStringConstants.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,9 @@ private static TruffleString ascii(String string) {
220220
}
221221

222222
public static TruffleString lookupUSASCIITString(String string) {
223-
if (string.length() == 1) {
223+
if (string.isEmpty()) {
224+
return EMPTY_US_ASCII;
225+
} else if (string.length() == 1) {
224226
return US_ASCII_SINGLE_BYTE[string.charAt(0)];
225227
} else {
226228
return TSTRING_CONSTANTS.get(string);

0 commit comments

Comments
 (0)