We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 7d9bc16 + 5b11dc3 commit b2a09d3Copy full SHA for b2a09d3
library/src/scala/quoted/Unlifted.scala
@@ -27,12 +27,13 @@ object Unlifted {
27
* }
28
* ```
29
*/
30
- def unapply[T](exprs: Seq[Expr[T]])(using unlift: Unliftable[T], qctx: Quotes): Option[Seq[T]] =
31
- exprs.foldRight(Option(List.empty[T])) { (elem, acc) =>
32
- (elem, acc) match {
33
- case (Unlifted(value), Some(lst)) => Some(value :: lst)
34
- case (_, _) => None
35
- }
36
+ def unapply[T](exprs: Seq[Expr[T]])(using Unliftable[T])(using Quotes): Option[Seq[T]] =
+ val builder = Seq.newBuilder[T]
+ val iter = exprs.iterator
+ while iter.hasNext do
+ iter.next() match
+ case Unlifted(value) => builder += value
+ case _ => return None
37
+ Some(builder.result())
38
39
}
0 commit comments