@@ -1448,8 +1448,8 @@ public AbstractStringBuilder insert(int dstOffset, CharSequence s,
14481448 shift (currValue , coder , count , dstOffset , len );
14491449 count += len ;
14501450 // Coder of CharSequence may be a mismatch, requiring the value array to be inflated
1451- byte [] newValue = (s instanceof String str )
1452- ? putStringAt (currValue , coder , count , dstOffset , str , start , end )
1451+ byte [] newValue = (s instanceof String str && str . length () == len )
1452+ ? putStringAt (currValue , coder , count , dstOffset , str )
14531453 : putCharsAt (currValue , coder , count , dstOffset , s , start , end );
14541454 if (currValue != newValue ) {
14551455 this .coder = UTF16 ;
@@ -1928,10 +1928,10 @@ private static byte[] inflateIfNeededFor(byte[] value, int count, byte coder, by
19281928 * @param index the index to insert the string
19291929 * @param str the string
19301930 */
1931- private static byte [] putStringAt (byte [] value , byte coder , int count , int index , String str , int off , int end ) {
1931+ private static byte [] putStringAt (byte [] value , byte coder , int count , int index , String str ) {
19321932 byte [] newValue = inflateIfNeededFor (value , count , coder , str .coder ());
19331933 coder = (newValue == value ) ? coder : UTF16 ;
1934- str .getBytes (newValue , off , index , coder , end - off );
1934+ str .getBytes (newValue , 0 , index , coder , str . length () );
19351935 return newValue ;
19361936 }
19371937
0 commit comments