From 1ca07ca89a8073757a06cb496a1fbc27ddf67592 Mon Sep 17 00:00:00 2001 From: Lucas Satabin Date: Mon, 17 Jul 2023 18:50:57 +0200 Subject: [PATCH] Make keyword acc function clearer in name and type The fact that it now returs `Unit` makes it clearer it is side effectful. --- .../fs2/data/json/internal/JsonTokenParser.scala | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/json/src/main/scala/fs2/data/json/internal/JsonTokenParser.scala b/json/src/main/scala/fs2/data/json/internal/JsonTokenParser.scala index f32567ca9..94d1c434a 100644 --- a/json/src/main/scala/fs2/data/json/internal/JsonTokenParser.scala +++ b/json/src/main/scala/fs2/data/json/internal/JsonTokenParser.scala @@ -226,13 +226,13 @@ 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 { @@ -240,11 +240,11 @@ private[json] class JsonTokenParser[F[_], T, Res]( 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)")) @@ -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)