From 4f22404e11fc2ef5ae457b6963acc951affccc55 Mon Sep 17 00:00:00 2001 From: plokhotnyuk Date: Fri, 9 Feb 2024 08:11:43 +0100 Subject: [PATCH] Code clean up --- .../plokhotnyuk/jsoniter_scala/core/JsonReader.scala | 12 ++++++------ .../plokhotnyuk/jsoniter_scala/core/JsonReader.scala | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/jsoniter-scala-core/jvm/src/main/scala/com/github/plokhotnyuk/jsoniter_scala/core/JsonReader.scala b/jsoniter-scala-core/jvm/src/main/scala/com/github/plokhotnyuk/jsoniter_scala/core/JsonReader.scala index 61b162c2b..d25246113 100644 --- a/jsoniter-scala-core/jvm/src/main/scala/com/github/plokhotnyuk/jsoniter_scala/core/JsonReader.scala +++ b/jsoniter-scala-core/jvm/src/main/scala/com/github/plokhotnyuk/jsoniter_scala/core/JsonReader.scala @@ -2883,12 +2883,12 @@ final class JsonReader private[jsoniter_scala]( private[this] def parseDuration(): Duration = { var b = nextByte(head) - var s = 0 + var s = 0L if (b == '-') { b = nextByte(head) - s = -1 + s = ~s } - if (b != 'P') durationOrPeriodStartError(s) + if (b != 'P') durationOrPeriodStartError(s.toInt) b = nextByte(head) var state = -1 if (b == 'T') { @@ -2903,7 +2903,7 @@ final class JsonReader private[jsoniter_scala]( b = nextByte(head) sx = ~sx } - if (b < '0' || b > '9') durationOrPeriodDigitError(s, sx, state) + if (b < '0' || b > '9') durationOrPeriodDigitError(s.toInt, sx.toInt, state) var x = ('0' - b).toLong var pos = head var buf = this.buf @@ -2934,7 +2934,7 @@ final class JsonReader private[jsoniter_scala]( seconds = sumSeconds((sx - (x ^ sx)) * 60, seconds, pos) state = 2 } else if (b == 'S' || b == '.') { - if ((sx | x) == -9223372036854775808L) durationError(pos) + if ((x | sx) == -9223372036854775808L) durationError(pos) seconds = sumSeconds(sx - (x ^ sx), seconds, pos) state = 3 if (b == '.') { @@ -2976,7 +2976,7 @@ final class JsonReader private[jsoniter_scala]( } } if (b != 'S') nanoError(nanoDigitWeight, 'S', pos) - nano = (nano ^ sx) - sx + nano = ((nano ^ sx) - sx).toInt } } else durationError(state, pos) b = nextByte(pos + 1) diff --git a/jsoniter-scala-core/native/src/main/scala/com/github/plokhotnyuk/jsoniter_scala/core/JsonReader.scala b/jsoniter-scala-core/native/src/main/scala/com/github/plokhotnyuk/jsoniter_scala/core/JsonReader.scala index 9fc62e8b5..d5ad7e239 100644 --- a/jsoniter-scala-core/native/src/main/scala/com/github/plokhotnyuk/jsoniter_scala/core/JsonReader.scala +++ b/jsoniter-scala-core/native/src/main/scala/com/github/plokhotnyuk/jsoniter_scala/core/JsonReader.scala @@ -2879,12 +2879,12 @@ final class JsonReader private[jsoniter_scala]( private[this] def parseDuration(): Duration = { var b = nextByte(head) - var s = 0 + var s = 0L if (b == '-') { b = nextByte(head) - s = -1 + s = ~s } - if (b != 'P') durationOrPeriodStartError(s) + if (b != 'P') durationOrPeriodStartError(s.toInt) b = nextByte(head) var state = -1 if (b == 'T') { @@ -2899,7 +2899,7 @@ final class JsonReader private[jsoniter_scala]( b = nextByte(head) sx = ~sx } - if (b < '0' || b > '9') durationOrPeriodDigitError(s, sx, state) + if (b < '0' || b > '9') durationOrPeriodDigitError(s.toInt, sx.toInt, state) var x = ('0' - b).toLong var pos = head var buf = this.buf @@ -2930,7 +2930,7 @@ final class JsonReader private[jsoniter_scala]( seconds = sumSeconds((sx - (x ^ sx)) * 60, seconds, pos) state = 2 } else if (b == 'S' || b == '.') { - if ((sx | x) == -9223372036854775808L) durationError(pos) + if ((x | sx) == -9223372036854775808L) durationError(pos) seconds = sumSeconds(sx - (x ^ sx), seconds, pos) state = 3 if (b == '.') { @@ -2972,7 +2972,7 @@ final class JsonReader private[jsoniter_scala]( } } if (b != 'S') nanoError(nanoDigitWeight, 'S', pos) - nano = (nano ^ sx) - sx + nano = ((nano ^ sx) - sx).toInt } } else durationError(state, pos) b = nextByte(pos + 1)