@@ -1114,6 +1114,7 @@ final class JsonWriter private[jsoniter_scala](
1114
1114
}
1115
1115
}
1116
1116
1117
+ @ inline
1117
1118
private [this ] def writeNestedStart (b : Byte ): Unit = {
1118
1119
writeOptionalCommaAndIndentionBeforeKey()
1119
1120
writeBytes(b)
@@ -1124,6 +1125,7 @@ final class JsonWriter private[jsoniter_scala](
1124
1125
}
1125
1126
}
1126
1127
1128
+ @ inline
1127
1129
private [this ] def writeNestedEnd (b : Byte ): Unit = {
1128
1130
comma = true
1129
1131
if (indention != 0 ) {
@@ -1290,6 +1292,7 @@ final class JsonWriter private[jsoniter_scala](
1290
1292
count = pos + 1
1291
1293
}
1292
1294
1295
+ @ inline
1293
1296
private [this ] def writeRawBytes (bs : Array [Byte ]): Unit = {
1294
1297
var pos = count
1295
1298
var step = Math .max(config.preferredBufSize, limit - pos)
@@ -1551,6 +1554,7 @@ final class JsonWriter private[jsoniter_scala](
1551
1554
count = pos + 1
1552
1555
}
1553
1556
1557
+ @ inline
1554
1558
private [this ] def writeEscapedUnicode (ch : Int , pos : Int , buf : Array [Byte ], ds : Array [Short ]): Int = {
1555
1559
buf(pos) = '\\ '
1556
1560
buf(pos + 1 ) = 'u'
@@ -1563,6 +1567,7 @@ final class JsonWriter private[jsoniter_scala](
1563
1567
pos + 6
1564
1568
}
1565
1569
1570
+ @ inline
1566
1571
private [this ] def writeEscapedUnicode (b : Byte , pos : Int , buf : Array [Byte ], ds : Array [Short ]): Int = {
1567
1572
buf(pos) = '\\ '
1568
1573
buf(pos + 1 ) = 'u'
@@ -1674,6 +1679,7 @@ final class JsonWriter private[jsoniter_scala](
1674
1679
writeBigDecimalRemainder(qr(1 ), scale, blockScale, n - 1 , ss)
1675
1680
}
1676
1681
1682
+ @ inline
1677
1683
private [this ] def calculateTenPow18SquareNumber (bitLen : Int ): Int = {
1678
1684
val m = Math .max((bitLen * 0.016723888647998956 ).toInt - 1 , 1 ) // Math.max((x.bitLength * Math.log(2) / Math.log(1e18)).toInt - 1, 1)
1679
1685
31 - java.lang.Integer .numberOfLeadingZeros(m)
@@ -1886,6 +1892,7 @@ final class JsonWriter private[jsoniter_scala](
1886
1892
writeInstant(year, month, day, secsOfDay, x.getNano)
1887
1893
}
1888
1894
1895
+ @ inline
1889
1896
private [this ] def writeInstant (year : Int , month : Int , day : Int , secsOfDay : Int , nano : Int ): Unit = {
1890
1897
var pos = ensureBufCapacity(39 ) // 39 == Instant.MAX.toString.length + 2
1891
1898
val buf = this .buf
@@ -2095,6 +2102,7 @@ final class JsonWriter private[jsoniter_scala](
2095
2102
write2Digits(month, pos + 1 , buf, ds)
2096
2103
}
2097
2104
2105
+ @ inline
2098
2106
private [this ] def writeYear (year : Int , pos : Int , buf : Array [Byte ], ds : Array [Short ]): Int =
2099
2107
if (year >= 0 && year < 10000 ) write4Digits(year, pos, buf, ds)
2100
2108
else writeYearWithSign(year, pos, buf, ds)
@@ -2185,13 +2193,15 @@ final class JsonWriter private[jsoniter_scala](
2185
2193
}
2186
2194
}
2187
2195
2196
+ @ inline
2188
2197
private [this ] def write2Digits (x : Int , pos : Int , buf : Array [Byte ], ds : Array [Short ]): Int = {
2189
2198
val d = ds(x)
2190
2199
buf(pos) = d.toByte
2191
2200
buf(pos + 1 ) = (d >> 8 ).toByte
2192
2201
pos + 2
2193
2202
}
2194
2203
2204
+ @ inline
2195
2205
private [this ] def write3Digits (x : Int , pos : Int , buf : Array [Byte ], ds : Array [Short ]): Int = {
2196
2206
val q1 = x * 1311 >> 17 // divide a small positive int by 100
2197
2207
buf(pos) = (q1 + '0' ).toByte
@@ -2201,6 +2211,7 @@ final class JsonWriter private[jsoniter_scala](
2201
2211
pos + 3
2202
2212
}
2203
2213
2214
+ @ inline
2204
2215
private [this ] def write4Digits (x : Int , pos : Int , buf : Array [Byte ], ds : Array [Short ]): Int = {
2205
2216
val q1 = x * 5243 >> 19 // divide a small positive int by 100
2206
2217
val d1 = ds(q1)
@@ -2212,6 +2223,7 @@ final class JsonWriter private[jsoniter_scala](
2212
2223
pos + 4
2213
2224
}
2214
2225
2226
+ @ inline
2215
2227
private [this ] def write8Digits (x : Int , pos : Int , buf : Array [Byte ], ds : Array [Short ]): Int = {
2216
2228
val q1 = x / 10000
2217
2229
val q2 = q1 * 5243 >> 19 // divide a small positive int by 100
@@ -2232,6 +2244,7 @@ final class JsonWriter private[jsoniter_scala](
2232
2244
pos + 8
2233
2245
}
2234
2246
2247
+ @ inline
2235
2248
private [this ] def write18Digits (x : Long , pos : Int , buf : Array [Byte ], ds : Array [Short ]): Int = {
2236
2249
val q1 = ((x >>> 8 ) * 2.56e-6 ).toLong // divide a medium positive long by 100000000
2237
2250
write8Digits((x - q1 * 100000000L ).toInt, {
@@ -2286,6 +2299,7 @@ final class JsonWriter private[jsoniter_scala](
2286
2299
count = pos
2287
2300
}
2288
2301
2302
+ @ inline
2289
2303
private [this ] def writeLong (x : Long ): Unit =
2290
2304
count = writeLong(x, ensureBufCapacity(20 ), buf) // Long.MinValue.toString.length
2291
2305
@@ -2456,6 +2470,7 @@ final class JsonWriter private[jsoniter_scala](
2456
2470
count = pos
2457
2471
}
2458
2472
2473
+ @ inline
2459
2474
private [this ] def rop (g : Long , cp : Int ): Int = {
2460
2475
val x = ((g & 0xFFFFFFFFL) * cp >>> 32 ) + (g >>> 32 ) * cp
2461
2476
(x >>> 31 ).toInt | - x.toInt >>> 31
@@ -2587,6 +2602,7 @@ final class JsonWriter private[jsoniter_scala](
2587
2602
count = pos
2588
2603
}
2589
2604
2605
+ @ inline
2590
2606
private [this ] def rop (g1 : Long , g0 : Long , cp : Long ): Long = {
2591
2607
val x = multiplyHigh(g0, cp) + (g1 * cp >>> 1 )
2592
2608
var y = multiplyHigh(g1, cp)
@@ -2595,6 +2611,7 @@ final class JsonWriter private[jsoniter_scala](
2595
2611
y
2596
2612
}
2597
2613
2614
+ @ inline
2598
2615
private [this ] def multiplyHigh (x : Long , y : Long ): Long = { // Karatsuba technique for two positive longs
2599
2616
val x2 = x & 0xFFFFFFFFL
2600
2617
val y2 = y & 0xFFFFFFFFL
@@ -2605,6 +2622,7 @@ final class JsonWriter private[jsoniter_scala](
2605
2622
((b >>> 32 ) + (x1 + x2) * (y1 + y2) - b - a >>> 32 ) + a
2606
2623
}
2607
2624
2625
+ @ inline
2608
2626
private [this ] def digitCount (q0 : Long ): Int =
2609
2627
if (q0 >= 1000000000000000L ) {
2610
2628
if (q0 >= 10000000000000000L ) 17
@@ -2708,6 +2726,7 @@ final class JsonWriter private[jsoniter_scala](
2708
2726
2709
2727
private [this ] def illegalNumberError (x : Double ): Nothing = encodeError(" illegal number: " + x)
2710
2728
2729
+ @ inline
2711
2730
private [this ] def ensureBufCapacity (required : Int ): Int = {
2712
2731
val pos = count
2713
2732
if (pos + required <= limit) pos
0 commit comments