Skip to content

Commit b88a21b

Browse files
authored
Code clean up
1 parent 3132eaf commit b88a21b

File tree

1 file changed

+8
-14
lines changed
  • jsoniter-scala-macros/shared/src/main/scala-3/com/github/plokhotnyuk/jsoniter_scala/macros

1 file changed

+8
-14
lines changed

jsoniter-scala-macros/shared/src/main/scala-3/com/github/plokhotnyuk/jsoniter_scala/macros/JsonCodecMaker.scala

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2219,10 +2219,8 @@ object JsonCodecMaker {
22192219
}
22202220
$x($i) = ${genReadVal(tpe1 :: types, genNullValue[t1](tpe1 :: types), isStringified, false, in)}
22212221
}, default.asExprOf[immutable.ArraySeq[t1]], (x, i, l) => '{
2222-
immutable.ArraySeq.unsafeWrapArray[t1]({
2223-
if ($i == $l) $x
2224-
else ${shrinkArray(x, i)}
2225-
})
2222+
if ($i != $l) ${Assign(x.asTerm, shrinkArray(x, i).asTerm).asExprOf[Unit]}
2223+
immutable.ArraySeq.unsafeWrapArray[t1]($x)
22262224
}.asExprOf[immutable.ArraySeq[t1]], in).asExprOf[T]
22272225
} else if (tpe <:< TypeRepr.of[mutable.ArraySeq[_]]) {
22282226
genReadArray(l => genNewArray[t1](l), (x, i, l) => '{
@@ -2232,10 +2230,8 @@ object JsonCodecMaker {
22322230
}
22332231
$x($i) = ${genReadVal(tpe1 :: types, genNullValue[t1](tpe1 :: types), isStringified, false, in)}
22342232
}, default.asExprOf[mutable.ArraySeq[t1]], (x, i, l) => '{
2235-
mutable.ArraySeq.make[t1]({
2236-
if ($i == $l) $x
2237-
else ${shrinkArray(x, i)}
2238-
})
2233+
if ($i != $l) ${Assign(x.asTerm, shrinkArray(x, i).asTerm).asExprOf[Unit]}
2234+
mutable.ArraySeq.make[t1]($x)
22392235
}.asExprOf[mutable.ArraySeq[t1]], in).asExprOf[T]
22402236
} else if (tpe.typeSymbol.fullName == "scala.IArray$package$.IArray") {
22412237
genReadArray(l => genNewArray[t1](l), (x, i, l) => '{
@@ -2245,10 +2241,8 @@ object JsonCodecMaker {
22452241
}
22462242
$x($i) = ${genReadVal(tpe1 :: types, genNullValue[t1](tpe1 :: types), isStringified, false, in)}
22472243
}, default.asExprOf[IArray[t1]], (x, i, l) => '{
2248-
IArray.unsafeFromArray[t1]({
2249-
if ($i == $l) $x
2250-
else ${shrinkArray(x, i)}
2251-
})
2244+
if ($i != $l) ${Assign(x.asTerm, shrinkArray(x, i).asTerm).asExprOf[Unit]}
2245+
IArray.unsafeFromArray[t1]($x)
22522246
}.asExprOf[IArray[t1]], in).asExprOf[T]
22532247
} else {
22542248
genReadArray(l => genNewArray[t1](l), (x, i, l) => '{
@@ -2258,8 +2252,8 @@ object JsonCodecMaker {
22582252
}
22592253
$x($i) = ${genReadVal(tpe1 :: types, genNullValue[t1](tpe1 :: types), isStringified, false, in)}
22602254
}, default.asExprOf[Array[t1]], (x, i, l) => '{
2261-
if ($i == $l) $x
2262-
else ${shrinkArray(x, i)}
2255+
if ($i != $l) ${Assign(x.asTerm, shrinkArray(x, i).asTerm).asExprOf[Unit]}
2256+
$x
22632257
}.asExprOf[Array[t1]], in).asExprOf[T]
22642258
}
22652259
} else if (tpe <:< TypeRepr.of[immutable.IntMap[_]]) withDecoderFor(methodKey, default, in) { (in, default) =>

0 commit comments

Comments
 (0)