@@ -182,7 +182,7 @@ private static boolean backslashreplace(TruffleEncoder encoder) {
182
182
}
183
183
i += Character .charCount (ch );
184
184
}
185
- encoder .replace (sb . toString (), p . length ());
185
+ encoder .replace (p . length (), sb . toString ());
186
186
return true ;
187
187
}
188
188
@@ -204,7 +204,7 @@ private static boolean surrogatepass(TruffleEncoder encoder) {
204
204
replacement [outp ++] = (byte ) (0x80 | (ch & 0x3f ));
205
205
i += Character .charCount (ch );
206
206
}
207
- encoder .replace (replacement , encoder .getErrorLenght ());
207
+ encoder .replace (encoder .getErrorLenght (), replacement , 0 , outp );
208
208
return true ;
209
209
}
210
210
return false ;
@@ -280,7 +280,7 @@ private static boolean backslashreplace(TruffleDecoder decoder) {
280
280
replacement [outp ++] = (char ) buf [2 ];
281
281
replacement [outp ++] = (char ) buf [3 ];
282
282
}
283
- decoder .replace (replacement , p .length );
283
+ decoder .replace (p .length , replacement , 0 , outp );
284
284
return true ;
285
285
}
286
286
@@ -293,7 +293,7 @@ private static boolean surrogatepass(TruffleDecoder decoder) {
293
293
if ((p [0 ] & 0xf0 ) == 0xe0 && (p [1 ] & 0xc0 ) == 0x80 && (p [2 ] & 0xc0 ) == 0x80 ) {
294
294
int codePoint = ((p [0 ] & 0x0f ) << 12 ) + ((p [1 ] & 0x3f ) << 6 ) + (p [2 ] & 0x3f );
295
295
if (0xD800 <= codePoint && codePoint <= 0xDFFF ) {
296
- decoder .replace (Character .toChars (codePoint ), 3 );
296
+ decoder .replace (3 , Character .toChars (codePoint ));
297
297
return true ;
298
298
}
299
299
}
@@ -646,16 +646,16 @@ public char[] getInputChars(int num) {
646
646
}
647
647
648
648
@ TruffleBoundary
649
- public void replace (byte [] replacement , int skipInput ) {
649
+ public void replace (int skipInput , byte [] replacement , int offset , int length ) {
650
650
while (outputBuffer .remaining () < replacement .length ) {
651
651
grow ();
652
652
}
653
- outputBuffer .put (replacement );
653
+ outputBuffer .put (replacement , offset , length );
654
654
inputBuffer .position (inputBuffer .position () + skipInput );
655
655
}
656
656
657
657
@ TruffleBoundary
658
- public void replace (String replacement , int skipInput ) {
658
+ public void replace (int skipInput , String replacement ) {
659
659
inputBuffer .position (inputBuffer .position () + skipInput );
660
660
CharBuffer newBuffer = CharBuffer .allocate (inputBuffer .remaining () + replacement .length ());
661
661
newBuffer .put (replacement );
@@ -752,12 +752,16 @@ public int getErrorLenght() {
752
752
return coderResult .length ();
753
753
}
754
754
755
+ public void replace (int skipInput , char [] chars ) {
756
+ replace (skipInput , chars , 0 , chars .length );
757
+ }
758
+
755
759
@ TruffleBoundary
756
- public void replace (char [] chars , int skipInput ) {
760
+ public void replace (int skipInput , char [] chars , int offset , int lenght ) {
757
761
while (outputBuffer .remaining () < chars .length ) {
758
762
grow ();
759
763
}
760
- outputBuffer .put (chars );
764
+ outputBuffer .put (chars , offset , lenght );
761
765
inputBuffer .position (inputBuffer .position () + skipInput );
762
766
}
763
767
0 commit comments