Skip to content

Commit

Permalink
Try to fix test failures
Browse files Browse the repository at this point in the history
  • Loading branch information
plokhotnyuk committed Mar 24, 2022
1 parent 6c2dba9 commit e66046d
Showing 1 changed file with 11 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -716,12 +716,7 @@ final class JsonWriter private[jsoniter_scala](
while (offset < lenM1) {
val offsetLim = Math.min(((posLim - pos + 1) >> 1) + offset, lenM1)
while (offset < offsetLim) {
val d1 = ds(bs(offset) & 0xFF)
val d2 = ds(bs(offset + 1) & 0xFF)
buf(pos) = d1.toByte
buf(pos + 1) = (d1 >> 8).toByte
buf(pos + 2) = d2.toByte
buf(pos + 3) = (d2 >> 8).toByte
ByteArrayAsInt.set(buf, pos, ds(bs(offset) & 0xFF) | (ds(bs(offset + 1) & 0xFF) << 16))
pos += 4
offset += 2
}
Expand All @@ -732,9 +727,7 @@ final class JsonWriter private[jsoniter_scala](
}
}
if (offset == lenM1) {
val d1 = ds(bs(offset) & 0xFF)
buf(pos) = d1.toByte
buf(pos + 1) = (d1 >> 8).toByte
ByteArrayAsShort.set(buf, pos, ds(bs(offset) & 0xFF))
pos += 2
}
buf(pos) = '"'
Expand Down Expand Up @@ -1209,15 +1202,11 @@ final class JsonWriter private[jsoniter_scala](
buf(pos) = (q0 + '0').toByte
pos + 1
} else if (q0 < 100) {
val d = digits(q0)
buf(pos) = d.toByte
buf(pos + 1) = (d >> 8).toByte
ByteArrayAsShort.set(buf, pos, digits(q0))
pos + 2
} else {
val d = digits(q0 - 100)
buf(pos) = '1'
buf(pos + 1) = d.toByte
buf(pos + 2) = (d >> 8).toByte
ByteArrayAsShort.set(buf, pos + 1, digits(q0 - 100))
pos + 3
}
}
Expand Down Expand Up @@ -1631,18 +1620,14 @@ final class JsonWriter private[jsoniter_scala](
}

private[this] def write2Digits(q0: Int, pos: Int, buf: Array[Byte], ds: Array[Short]): Int = {
val d = ds(q0)
buf(pos) = d.toByte
buf(pos + 1) = (d >> 8).toByte
ByteArrayAsShort.set(buf, pos, ds(q0))
pos + 2
}

private[this] def write3Digits(q0: Int, pos: Int, buf: Array[Byte], ds: Array[Short]): Int = {
val q1 = q0 * 1311 >> 17 // divide a small positive int by 100
buf(pos) = (q1 + '0').toByte
val d = ds(q0 - q1 * 100)
buf(pos + 1) = d.toByte
buf(pos + 2) = (d >> 8).toByte
ByteArrayAsShort.set(buf, pos + 1, ds(q0 - q1 * 100))
pos + 3
}

Expand Down Expand Up @@ -2033,9 +2018,12 @@ final class JsonWriter private[jsoniter_scala](
pos -= 2
}
val d = ds(q0 - q1 * 100)
ByteArrayAsShort.set(buf, pos - 1, d)
buf(pos - 1) = d.toByte
var lastPos = pos
if (d > 12345) lastPos += 1 // 12345 == ('0' << 8) | '9'
if (d > 12345) { // 12345 == ('0' << 8) | '9'
buf(pos) = (d >> 8).toByte
lastPos += 1
}
writeFractionDigits(q1, pos - 2, posLim, buf, ds)
lastPos
}
Expand Down

0 comments on commit e66046d

Please sign in to comment.