Skip to content

Commit bc74e6d

Browse files
committed
Clean up of benchmarks
1 parent 7df1e7f commit bc74e6d

File tree

4 files changed

+14
-15
lines changed

4 files changed

+14
-15
lines changed

jsoniter-scala-benchmark/shared/src/main/scala/com/github/plokhotnyuk/jsoniter_scala/benchmark/BorerJsonEncodersDecoders.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import java.util.UUID
66
import java.util.concurrent.ConcurrentHashMap
77
import com.github.plokhotnyuk.jsoniter_scala.benchmark.SuitEnum.SuitEnum
88
import io.bullet.borer.{AdtEncodingStrategy, Codec, Decoder, Encoder, Reader, Writer}
9-
import io.bullet.borer.Borer.Error._
109
import io.bullet.borer.Json.DecodingConfig
1110
import io.bullet.borer.derivation.ArrayBasedCodecs
1211
import io.bullet.borer.derivation.MapBasedCodecs._

jsoniter-scala-benchmark/shared/src/main/scala/com/github/plokhotnyuk/jsoniter_scala/benchmark/Json4sFormats.scala

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,37 +47,37 @@ object AnyValsJson4sFormats {
4747
new CustomSerializer[ByteVal](_ => ({
4848
case JInt(x) if x.isValidByte => new ByteVal(x.toByte)
4949
}, {
50-
case x: ByteVal => JInt(BigInt(x.a))
50+
case x: ByteVal => new JLong(x.a.toLong)
5151
})) +
5252
new CustomSerializer[ShortVal](_ => ({
5353
case JInt(x) if x.isValidShort => new ShortVal(x.toShort)
5454
}, {
55-
case x: ShortVal => JInt(BigInt(x.a))
55+
case x: ShortVal => new JLong(x.a.toLong)
5656
})) +
5757
new CustomSerializer[IntVal](_ => ({
5858
case JInt(x) if x.isValidInt => new IntVal(x.toInt)
5959
}, {
60-
case x: IntVal => JInt(x.a)
60+
case x: IntVal => new JLong(x.a.toLong)
6161
})) +
6262
new CustomSerializer[LongVal](_ => ({
63-
case JInt(x) if x.isValidLong => new LongVal(x.toInt)
63+
case JInt(x) if x.isValidLong => new LongVal(x.toLong)
6464
}, {
65-
case x: LongVal => JInt(x.a)
65+
case x: LongVal => new JLong(x.a)
6666
})) +
6767
new CustomSerializer[FloatVal](_ => ({
6868
case JDecimal(x) => new FloatVal(x.toFloat)
6969
}, {
70-
case x: FloatVal => JDecimal(BigDecimal(x.a))
70+
case x: FloatVal => new JDecimal(BigDecimal(x.a))
7171
})) +
7272
new CustomSerializer[DoubleVal](_ => ({
73-
case JDouble(x) => new DoubleVal(x.toFloat)
73+
case JDouble(x) => new DoubleVal(x)
7474
}, {
75-
case x: DoubleVal => JDecimal(x.a)
75+
case x: DoubleVal => new JDecimal(x.a)
7676
})) +
7777
new CustomSerializer[CharVal](_ => ({
7878
case JString(x) if x.length == 1 => new CharVal(x.charAt(0))
7979
}, {
80-
case x: CharVal => JString(x.a.toString)
80+
case x: CharVal => new JString(x.a.toString)
8181
}))
8282
}
8383

@@ -109,7 +109,7 @@ object GeoJsonJson4sFormats {
109109
new CustomSerializer[Tuple2[Double, Double]](_ => ({
110110
case JArray(JDouble(x) :: JDouble(y) :: Nil) => new Tuple2[Double, Double](x, y)
111111
}, {
112-
case (x: Double, y: Double) => JArray(JDouble(x) :: JDouble(y) :: Nil)
112+
case (x: Double, y: Double) => new JArray(new JDouble(x) :: new JDouble(y) :: Nil)
113113
}))
114114
}
115115

jsoniter-scala-benchmark/shared/src/main/scala/com/github/plokhotnyuk/jsoniter_scala/benchmark/PlayJsonFormats.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ object PlayJsonFormats {
1818

1919
implicit def mutableMapReads[A, B](implicit mapReads: Reads[Map[A, B]]): Reads[mutable.Map[A, B]] =
2020
Reads[mutable.Map[A, B]](js => JsSuccess(js.as[Map[A, B]].foldLeft(mutable.Map.empty[A, B]) {
21-
(m, p) => m += ((p._1, p._2))
21+
(m, p) => m.addOne(p)
2222
}))
2323

2424
implicit def mutableLongMapFormat[A](implicit mapReads: Reads[Map[Long, A]],
@@ -32,7 +32,7 @@ object PlayJsonFormats {
3232

3333
override def writes(v: mutable.LongMap[A]): JsValue =
3434
Json.toJsObject(v.foldLeft(mutable.LinkedHashMap.empty[String, JsValue]) {
35-
(m, p) => m += ((p._1.toString, aWrites.writes(p._2)))
35+
(m, p) => m.addOne((p._1.toString, aWrites.writes(p._2)))
3636
})
3737
}
3838

@@ -43,7 +43,7 @@ object PlayJsonFormats {
4343

4444
override def writes(v: IntMap[A]): JsValue =
4545
Json.toJsObject(v.foldLeft(mutable.LinkedHashMap.empty[String, JsValue]) {
46-
(m, p) => m += ((p._1.toString, aWrites.writes(p._2)))
46+
(m, p) => m.addOne((p._1.toString, aWrites.writes(p._2)))
4747
})
4848
}
4949

jsoniter-scala-benchmark/shared/src/main/scala/com/github/plokhotnyuk/jsoniter_scala/benchmark/ZioJSONEncoderDecoders.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ object ZioJSONEncoderDecoders {
133133
var i: Int = 0
134134
if (Lexer.firstArrayElement(in)) {
135135
while ({
136-
builder += decoder.unsafeDecode(JsonError.ArrayAccess(i) :: trace, in)
136+
builder.addOne(decoder.unsafeDecode(JsonError.ArrayAccess(i) :: trace, in))
137137
i += 1
138138
Lexer.nextArrayElement(trace, in)
139139
}) ()

0 commit comments

Comments
 (0)