From b55d4becbd0f21a1cb2d63a7bdd29fe359848772 Mon Sep 17 00:00:00 2001 From: Jamie Willis Date: Mon, 30 Jan 2023 20:50:11 +0000 Subject: [PATCH] Remove unnecessary `clear` during sequence merging (#157) --- .../internal/deepembedding/backend/SequenceEmbedding.scala | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/parsley/shared/src/main/scala/parsley/internal/deepembedding/backend/SequenceEmbedding.scala b/parsley/shared/src/main/scala/parsley/internal/deepembedding/backend/SequenceEmbedding.scala index c9d63166b..c865b2fa0 100644 --- a/parsley/shared/src/main/scala/parsley/internal/deepembedding/backend/SequenceEmbedding.scala +++ b/parsley/shared/src/main/scala/parsley/internal/deepembedding/backend/SequenceEmbedding.scala @@ -137,8 +137,6 @@ private [deepembedding] final class Seq[A](private [backend] var before: DoublyL } private def mergeFromRight(p: Seq[_], into: DoublyLinkedList[StrictParsley[_]]): this.type = { - assume(after.isEmpty || after.size == 1 && (after.head eq p), "after can only contain just p, which is going to get flattened") - after.clear() into.stealAll(p.before) Seq.whenNonPure(p.res, into.addOne(_)) into.stealAll(p.after) @@ -173,6 +171,7 @@ private [deepembedding] final class Seq[A](private [backend] var before: DoublyL before = rs1 res = rr assume(!rr.isInstanceOf[Pure[_]] || rs2.isEmpty, "rs2 is empty when rr is Pure") + assume(after.size == 1 && (after.head eq p), "after can only contain just p, which is going to get flattened, so it can be dropped") after = rs2 val into = chooseInto(rr) p match {