Skip to content

Commit a003b18

Browse files
committed
Code clean up
1 parent 5778631 commit a003b18

File tree

3 files changed

+7
-12
lines changed
  • jsoniter-scala-core

3 files changed

+7
-12
lines changed

jsoniter-scala-core/js/src/main/scala/com/github/plokhotnyuk/jsoniter_scala/core/JsonWriter.scala

+7-10
Original file line numberDiff line numberDiff line change
@@ -940,7 +940,6 @@ final class JsonWriter private[jsoniter_scala](
940940
*/
941941
def writeArrayStart(): Unit = writeNestedStart('[')
942942

943-
944943
/**
945944
* Writes a JSON array end marker (`]`).
946945
*/
@@ -1622,10 +1621,9 @@ final class JsonWriter private[jsoniter_scala](
16221621
pos += digitCount(q)
16231622
count = pos
16241623
} else {
1625-
val q1 = (exp >>> 8) * 1441151881L >>> 49 // divide a small positive long by 100000000
1626-
q = q1.toInt
1627-
pos += digitCount(q)
1628-
count = write8Digits((exp - q1 * 100000000L).toInt, pos, buf, ds)
1624+
q = (exp * 1e-8).toInt // divide a small positive long by 100000000
1625+
pos += ((9 - q) >>> 31) + 1
1626+
count = write8Digits((exp - q * 100000000L).toInt, pos, buf, ds)
16291627
}
16301628
writePositiveIntDigits(q, pos, buf, ds)
16311629
}
@@ -2403,10 +2401,9 @@ final class JsonWriter private[jsoniter_scala](
24032401
lastPos += digitCount(q)
24042402
pos = lastPos
24052403
} else {
2406-
val q2 = (q1 >>> 8) * 1441151881L >>> 49 // divide a small positive long by 100000000
2407-
q = q2.toInt
2408-
lastPos += digitCount(q)
2409-
pos = write8Digits((q1 - q2 * 100000000L).toInt, lastPos, buf, ds)
2404+
q = ((q1 >>> 8) * 1441151881L >>> 49).toInt // divide a small positive long by 100000000
2405+
lastPos += ((9 - q) >>> 31) + 1
2406+
pos = write8Digits((q1 - q * 100000000L).toInt, lastPos, buf, ds)
24102407
}
24112408
pos = write8Digits((q0 - q1 * 100000000L).toInt, pos, buf, ds) + posCorr
24122409
}
@@ -2452,7 +2449,7 @@ final class JsonWriter private[jsoniter_scala](
24522449
cblCorr = 1
24532450
}
24542451
e10 = e2 * 315653 - e2Corr >> 20
2455-
val g = gs(e10 + 324 << 1) + 1
2452+
val g = gs(e10 + 324 << 1) + 1L
24562453
val h = (e10 * -108853 >> 15) + e2 + 1
24572454
val cb = m2 << 2
24582455
val vbCorr = (m2 & 0x1) - 1

jsoniter-scala-core/jvm/src/main/scala/com/github/plokhotnyuk/jsoniter_scala/core/JsonWriter.scala

-1
Original file line numberDiff line numberDiff line change
@@ -869,7 +869,6 @@ final class JsonWriter private[jsoniter_scala](
869869
*/
870870
def writeArrayStart(): Unit = writeNestedStart('[')
871871

872-
873872
/**
874873
* Writes a JSON array end marker (`]`).
875874
*/

jsoniter-scala-core/native/src/main/scala/com/github/plokhotnyuk/jsoniter_scala/core/JsonWriter.scala

-1
Original file line numberDiff line numberDiff line change
@@ -869,7 +869,6 @@ final class JsonWriter private[jsoniter_scala](
869869
*/
870870
def writeArrayStart(): Unit = writeNestedStart('[')
871871

872-
873872
/**
874873
* Writes a JSON array end marker (`]`).
875874
*/

0 commit comments

Comments
 (0)