@@ -1311,7 +1311,7 @@ final class JsonWriter private[jsoniter_scala](
1311
1311
}
1312
1312
1313
1313
private [this ] def writeEscapedOrEncodedString (s : String , from : Int , pos : Int ): Int =
1314
- if (config.escapeUnicode) writeEscapedString(s, from, s.length, pos, limit - 13 , escapedChars)
1314
+ if (config.escapeUnicode) writeEscapedString(s, from, s.length, pos, limit - 13 , escapedChars, lowerCaseHexDigits )
1315
1315
else writeEncodedString(s, from, s.length, pos, limit - 7 , escapedChars)
1316
1316
1317
1317
@ tailrec
@@ -1328,7 +1328,7 @@ final class JsonWriter private[jsoniter_scala](
1328
1328
} else if (esc > 0 ) {
1329
1329
ByteArrayAccess .setShort(buf, pos, (esc << 8 | 0x5C ).toShort)
1330
1330
writeEncodedString(s, from + 1 , to, pos + 2 , posLim, escapedChars)
1331
- } else writeEncodedString(s, from + 1 , to, writeEscapedUnicode(ch1.toByte, pos, buf), posLim, escapedChars)
1331
+ } else writeEncodedString(s, from + 1 , to, writeEscapedUnicode(ch1.toByte, pos, buf, lowerCaseHexDigits ), posLim, escapedChars)
1332
1332
} else if (ch1 < 0x800 ) { // 00000bbbbbaaaaaa (UTF-16 char) -> 110bbbbb 10aaaaaa (UTF-8 bytes)
1333
1333
ByteArrayAccess .setShort(buf, pos, (ch1 >> 6 | (ch1 << 8 & 0x3F00 ) | 0x80C0 ).toShort)
1334
1334
writeEncodedString(s, from + 1 , to, pos + 2 , posLim, escapedChars)
@@ -1348,29 +1348,29 @@ final class JsonWriter private[jsoniter_scala](
1348
1348
}
1349
1349
1350
1350
@ tailrec
1351
- private [this ] def writeEscapedString (s : String , from : Int , to : Int , pos : Int , posLim : Int , escapedChars : Array [Byte ]): Int =
1351
+ private [this ] def writeEscapedString (s : String , from : Int , to : Int , pos : Int , posLim : Int , escapedChars : Array [Byte ], ds : Array [ Short ] ): Int =
1352
1352
if (from >= to) pos
1353
- else if (pos >= posLim) writeEscapedString(s, from, to, flushAndGrowBuf(13 , pos), limit - 12 , escapedChars)
1353
+ else if (pos >= posLim) writeEscapedString(s, from, to, flushAndGrowBuf(13 , pos), limit - 12 , escapedChars, ds )
1354
1354
else {
1355
1355
val ch1 = s.charAt(from).toInt
1356
1356
if (ch1 < 0x80 ) {
1357
1357
val esc = escapedChars(ch1)
1358
1358
if (esc == 0 ) {
1359
1359
buf(pos) = ch1.toByte
1360
- writeEscapedString(s, from + 1 , to, pos + 1 , posLim, escapedChars)
1360
+ writeEscapedString(s, from + 1 , to, pos + 1 , posLim, escapedChars, ds )
1361
1361
} else if (esc > 0 ) {
1362
1362
ByteArrayAccess .setShort(buf, pos, (esc << 8 | 0x5C ).toShort)
1363
- writeEscapedString(s, from + 1 , to, pos + 2 , posLim, escapedChars)
1364
- } else writeEscapedString(s, from + 1 , to, writeEscapedUnicode(ch1.toByte, pos, buf), posLim, escapedChars)
1363
+ writeEscapedString(s, from + 1 , to, pos + 2 , posLim, escapedChars, ds )
1364
+ } else writeEscapedString(s, from + 1 , to, writeEscapedUnicode(ch1.toByte, pos, buf, ds ), posLim, escapedChars, ds )
1365
1365
} else if ((ch1 & 0xF800 ) != 0xD800 ) {
1366
- writeEscapedString(s, from + 1 , to, writeEscapedUnicode(ch1, pos, buf), posLim, escapedChars)
1366
+ writeEscapedString(s, from + 1 , to, writeEscapedUnicode(ch1, pos, buf, ds ), posLim, escapedChars, ds )
1367
1367
} else {
1368
1368
var ch2 = 0
1369
1369
if (ch1 >= 0xDC00 || from + 1 >= to || {
1370
1370
ch2 = s.charAt(from + 1 ).toInt
1371
1371
(ch2 & 0xFC00 ) != 0xDC00
1372
1372
}) illegalSurrogateError()
1373
- writeEscapedString(s, from + 2 , to, writeEscapedUnicode(ch2, writeEscapedUnicode(ch1, pos, buf), buf), posLim, escapedChars)
1373
+ writeEscapedString(s, from + 2 , to, writeEscapedUnicode(ch2, writeEscapedUnicode(ch1, pos, buf, ds ), buf, ds ), posLim, escapedChars, ds )
1374
1374
}
1375
1375
}
1376
1376
@@ -1406,17 +1406,15 @@ final class JsonWriter private[jsoniter_scala](
1406
1406
count = pos
1407
1407
}
1408
1408
1409
- private [this ] def writeEscapedUnicode (ch : Int , pos : Int , buf : Array [Byte ]): Int = {
1410
- val ds = lowerCaseHexDigits
1409
+ private [this ] def writeEscapedUnicode (ch : Int , pos : Int , buf : Array [Byte ], ds : Array [Short ]): Int = {
1411
1410
ByteArrayAccess .setShort(buf, pos, 0x755C )
1412
1411
val d1 = ds(ch >> 8 )
1413
1412
val d2 = ds(ch & 0xFF ) << 16
1414
1413
ByteArrayAccess .setInt(buf, pos + 2 , d1 | d2)
1415
1414
pos + 6
1416
1415
}
1417
1416
1418
- private [this ] def writeEscapedUnicode (b : Byte , pos : Int , buf : Array [Byte ]): Int = {
1419
- val ds = lowerCaseHexDigits
1417
+ private [this ] def writeEscapedUnicode (b : Byte , pos : Int , buf : Array [Byte ], ds : Array [Short ]): Int = {
1420
1418
ByteArrayAccess .setInt(buf, pos, 0x3030755C )
1421
1419
ByteArrayAccess .setShort(buf, pos + 4 , ds(b & 0xFF ))
1422
1420
pos + 6
0 commit comments