File tree Expand file tree Collapse file tree 3 files changed +18
-6
lines changed
js/src/main/scala/com/github/plokhotnyuk/jsoniter_scala/core
jvm/src/main/scala/com/github/plokhotnyuk/jsoniter_scala/core
native/src/main/scala/com/github/plokhotnyuk/jsoniter_scala/core Expand file tree Collapse file tree 3 files changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -1771,8 +1771,12 @@ final class JsonWriter private[jsoniter_scala](
17711771 val effectiveTotalSecs =
17721772 if (totalSecs < 0 ) (- nano >> 31 ) - totalSecs
17731773 else totalSecs
1774- val hours = effectiveTotalSecs / 3600
1775- val secsOfHour = (effectiveTotalSecs - hours * 3600 ).toInt
1774+ var hours = 0L
1775+ var secsOfHour = effectiveTotalSecs.toInt
1776+ if (effectiveTotalSecs >= 3600 ) {
1777+ hours = effectiveTotalSecs / 3600
1778+ secsOfHour = (effectiveTotalSecs - (hours << 12 ) + (hours << 9 ) - (hours << 4 )).toInt // (effectiveTotalSecs - hours * 3600).toInt
1779+ }
17761780 val minutes = secsOfHour * 17477 >> 20 // divide a small positive int by 60
17771781 val seconds = secsOfHour - minutes * 60
17781782 val ds = digits
Original file line number Diff line number Diff line change @@ -1598,8 +1598,12 @@ final class JsonWriter private[jsoniter_scala](
15981598 val effectiveTotalSecs =
15991599 if (totalSecs < 0 ) (- nano >> 31 ) - totalSecs
16001600 else totalSecs
1601- val hours = Math .multiplyHigh(effectiveTotalSecs >> 4 , 655884233731895169L ) >> 3 // divide a positive long by 3600
1602- val secsOfHour = (effectiveTotalSecs - hours * 3600 ).toInt
1601+ var hours = 0L
1602+ var secsOfHour = effectiveTotalSecs.toInt
1603+ if (effectiveTotalSecs >= 3600 ) {
1604+ hours = Math .multiplyHigh(effectiveTotalSecs >> 4 , 655884233731895169L ) >> 3 // divide a positive long by 3600
1605+ secsOfHour = (effectiveTotalSecs - hours * 3600 ).toInt
1606+ }
16031607 val minutes = secsOfHour * 17477 >> 20 // divide a small positive int by 60
16041608 val seconds = secsOfHour - minutes * 60
16051609 val ds = digits
Original file line number Diff line number Diff line change @@ -1598,8 +1598,12 @@ final class JsonWriter private[jsoniter_scala](
15981598 val effectiveTotalSecs =
15991599 if (totalSecs < 0 ) (- nano >> 31 ) - totalSecs
16001600 else totalSecs
1601- val hours = NativeMath .multiplyHigh(effectiveTotalSecs >> 4 , 655884233731895169L ) >> 3 // divide a positive long by 3600
1602- val secsOfHour = (effectiveTotalSecs - hours * 3600 ).toInt
1601+ var hours = 0L
1602+ var secsOfHour = effectiveTotalSecs.toInt
1603+ if (effectiveTotalSecs >= 3600 ) {
1604+ hours = NativeMath .multiplyHigh(effectiveTotalSecs >> 4 , 655884233731895169L ) >> 3 // divide a positive long by 3600
1605+ secsOfHour = (effectiveTotalSecs - hours * 3600 ).toInt
1606+ }
16031607 val minutes = secsOfHour * 17477 >> 20 // divide a small positive int by 60
16041608 val seconds = secsOfHour - minutes * 60
16051609 val ds = digits
You can’t perform that action at this time.
0 commit comments