Skip to content

Commit 4f22404

Browse files
committed
Code clean up
1 parent 62c4856 commit 4f22404

File tree

2 files changed

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

2 files changed

+12
-12
lines changed

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

+6-6
Original file line numberDiff line numberDiff line change
@@ -2883,12 +2883,12 @@ final class JsonReader private[jsoniter_scala](
28832883

28842884
private[this] def parseDuration(): Duration = {
28852885
var b = nextByte(head)
2886-
var s = 0
2886+
var s = 0L
28872887
if (b == '-') {
28882888
b = nextByte(head)
2889-
s = -1
2889+
s = ~s
28902890
}
2891-
if (b != 'P') durationOrPeriodStartError(s)
2891+
if (b != 'P') durationOrPeriodStartError(s.toInt)
28922892
b = nextByte(head)
28932893
var state = -1
28942894
if (b == 'T') {
@@ -2903,7 +2903,7 @@ final class JsonReader private[jsoniter_scala](
29032903
b = nextByte(head)
29042904
sx = ~sx
29052905
}
2906-
if (b < '0' || b > '9') durationOrPeriodDigitError(s, sx, state)
2906+
if (b < '0' || b > '9') durationOrPeriodDigitError(s.toInt, sx.toInt, state)
29072907
var x = ('0' - b).toLong
29082908
var pos = head
29092909
var buf = this.buf
@@ -2934,7 +2934,7 @@ final class JsonReader private[jsoniter_scala](
29342934
seconds = sumSeconds((sx - (x ^ sx)) * 60, seconds, pos)
29352935
state = 2
29362936
} else if (b == 'S' || b == '.') {
2937-
if ((sx | x) == -9223372036854775808L) durationError(pos)
2937+
if ((x | sx) == -9223372036854775808L) durationError(pos)
29382938
seconds = sumSeconds(sx - (x ^ sx), seconds, pos)
29392939
state = 3
29402940
if (b == '.') {
@@ -2976,7 +2976,7 @@ final class JsonReader private[jsoniter_scala](
29762976
}
29772977
}
29782978
if (b != 'S') nanoError(nanoDigitWeight, 'S', pos)
2979-
nano = (nano ^ sx) - sx
2979+
nano = ((nano ^ sx) - sx).toInt
29802980
}
29812981
} else durationError(state, pos)
29822982
b = nextByte(pos + 1)

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

+6-6
Original file line numberDiff line numberDiff line change
@@ -2879,12 +2879,12 @@ final class JsonReader private[jsoniter_scala](
28792879

28802880
private[this] def parseDuration(): Duration = {
28812881
var b = nextByte(head)
2882-
var s = 0
2882+
var s = 0L
28832883
if (b == '-') {
28842884
b = nextByte(head)
2885-
s = -1
2885+
s = ~s
28862886
}
2887-
if (b != 'P') durationOrPeriodStartError(s)
2887+
if (b != 'P') durationOrPeriodStartError(s.toInt)
28882888
b = nextByte(head)
28892889
var state = -1
28902890
if (b == 'T') {
@@ -2899,7 +2899,7 @@ final class JsonReader private[jsoniter_scala](
28992899
b = nextByte(head)
29002900
sx = ~sx
29012901
}
2902-
if (b < '0' || b > '9') durationOrPeriodDigitError(s, sx, state)
2902+
if (b < '0' || b > '9') durationOrPeriodDigitError(s.toInt, sx.toInt, state)
29032903
var x = ('0' - b).toLong
29042904
var pos = head
29052905
var buf = this.buf
@@ -2930,7 +2930,7 @@ final class JsonReader private[jsoniter_scala](
29302930
seconds = sumSeconds((sx - (x ^ sx)) * 60, seconds, pos)
29312931
state = 2
29322932
} else if (b == 'S' || b == '.') {
2933-
if ((sx | x) == -9223372036854775808L) durationError(pos)
2933+
if ((x | sx) == -9223372036854775808L) durationError(pos)
29342934
seconds = sumSeconds(sx - (x ^ sx), seconds, pos)
29352935
state = 3
29362936
if (b == '.') {
@@ -2972,7 +2972,7 @@ final class JsonReader private[jsoniter_scala](
29722972
}
29732973
}
29742974
if (b != 'S') nanoError(nanoDigitWeight, 'S', pos)
2975-
nano = (nano ^ sx) - sx
2975+
nano = ((nano ^ sx) - sx).toInt
29762976
}
29772977
} else durationError(state, pos)
29782978
b = nextByte(pos + 1)

0 commit comments

Comments
 (0)