Skip to content

Commit c5dddd9

Browse files
committed
More efficient serialization of Double and big java.time.Duration values using Scala.js
1 parent 39bf5d5 commit c5dddd9

File tree

1 file changed

+3
-4
lines changed
  • jsoniter-scala-core/js/src/main/scala/com/github/plokhotnyuk/jsoniter_scala/core

1 file changed

+3
-4
lines changed

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1787,10 +1787,9 @@ final class JsonWriter private[jsoniter_scala](
17871787
lastPos += digitCount(q)
17881788
pos = lastPos
17891789
} else {
1790-
val q1 = hours / 100000000
1791-
q = q1.toInt
1790+
q = ((hours >>> 8) * 2.56e-6).toInt
17921791
lastPos += digitCount(q)
1793-
pos = write8Digits((hours - q1 * 100000000).toInt, lastPos, buf, ds)
1792+
pos = write8Digits((hours - q * 100000000L).toInt, lastPos, buf, ds)
17941793
}
17951794
writePositiveIntDigits(q, lastPos, buf, ds)
17961795
buf(pos) = 'H'
@@ -2588,7 +2587,7 @@ final class JsonWriter private[jsoniter_scala](
25882587
var pos = p
25892588
var posLim = pl
25902589
if (q0 != x) {
2591-
val q1 = (x / 100000000).toInt // divide a positive long by 100000000
2590+
val q1 = ((x >>> 8) * 2.56e-6).toInt // divide a positive long by 100000000
25922591
val r1 = (x - q1 * 100000000L).toInt
25932592
val posm8 = pos - 8
25942593
if (r1 == 0) {

0 commit comments

Comments
 (0)