@@ -450,19 +450,16 @@ public void createNewBignum(BigInteger value) {
450
450
451
451
public void createNewString (ArrayCallback callback , int count , Encoding encoding ) {
452
452
loadRuntime ();
453
-
454
- method .newobj (p (ByteList .class ));
455
- method .dup ();
456
- method .ldc (StandardASMCompiler .STARTING_DSTR_SIZE );
457
- method .invokespecial (p (ByteList .class ), "<init>" , sig (Void .TYPE , int .class ));
453
+ ByteList startingDstr = new ByteList (StandardASMCompiler .STARTING_DSTR_SIZE );
458
454
459
455
if (encoding != null ) {
460
- script .getCacheCompiler ().cacheEncoding (this , encoding );
461
- method .ldc (StringSupport .CR_7BIT );
462
- method .invokestatic (p (RubyString .class ), "newStringNoCopy" , sig (RubyString .class , Ruby .class , ByteList .class , Encoding .class , int .class ));
463
- } else {
464
- method .invokestatic (p (RubyString .class ), "newStringLight" , sig (RubyString .class , Ruby .class , ByteList .class ));
456
+ startingDstr .setEncoding (encoding );
465
457
}
458
+
459
+ script .getCacheCompiler ().cacheByteList (this , startingDstr );
460
+ method .invokevirtual (p (ByteList .class ), "dup" , sig (ByteList .class ));
461
+ method .ldc (StringSupport .CR_7BIT );
462
+ method .invokestatic (p (RubyString .class ), "newStringShared" , sig (RubyString .class , Ruby .class , ByteList .class , int .class ));
466
463
467
464
for (int i = 0 ; i < count ; i ++) {
468
465
callback .nextValue (this , null , i );
0 commit comments