Skip to content

Commit

Permalink
Make keyword acc function clearer in name and type
Browse files Browse the repository at this point in the history
The fact that it now returs `Unit` makes it clearer it is side
effectful.
  • Loading branch information
satabin committed Jul 17, 2023
1 parent 814845d commit 1ca07ca
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions json/src/main/scala/fs2/data/json/internal/JsonTokenParser.scala
Original file line number Diff line number Diff line change
Expand Up @@ -226,25 +226,25 @@ private[json] class JsonTokenParser[F[_], T, Res](
private final def keyword_(expected: String,
eidx: Int,
elen: Int,
accumulate: () => ChunkAccumulator[Res]): Pull[F, Res, Unit] = {
processToken: () => Unit): Pull[F, Res, Unit] = {
if (T.needsPull(context)) {
emitChunk() >> T.pullNext(context).flatMap {
case Some(context) =>
this.context = context
chunkAcc.flush()
keyword_(expected, eidx, elen, accumulate)
keyword_(expected, eidx, elen, processToken)
case None => Pull.raiseError[F](new JsonException("unexpected end of input"))
}
} else {
val c = T.current(context)
if (c == expected.charAt(eidx)) {
if (eidx == elen - 1) {
T.advance(context)
accumulate()
processToken()
Pull.done
} else {
T.advance(context)
keyword_(expected, eidx + 1, elen, accumulate)
keyword_(expected, eidx + 1, elen, processToken)
}
} else {
emitChunk() >> Pull.raiseError[F](new JsonException(s"unexpected character '$c' (expected $expected)"))
Expand Down Expand Up @@ -272,9 +272,9 @@ private[json] class JsonTokenParser[F[_], T, Res](
T.advance(context)
chunkAcc.startArray()
Pull.suspend(go_(State.BeforeArrayValue))
case 't' => keyword_("true", 0, 4, chunkAcc.trueValue)
case 'f' => keyword_("false", 0, 5, chunkAcc.falseValue)
case 'n' => keyword_("null", 0, 4, chunkAcc.nullValue)
case 't' => keyword_("true", 0, 4, chunkAcc.trueValue _)
case 'f' => keyword_("false", 0, 5, chunkAcc.falseValue _)
case 'n' => keyword_("null", 0, 4, chunkAcc.nullValue _)
case '"' =>
T.advance(context)
T.mark(context)
Expand Down

0 comments on commit 1ca07ca

Please sign in to comment.