We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 176daf2 + 12d837b commit 4ff2ad9Copy full SHA for 4ff2ad9
tests/bench/string-interpolation-macro/Macro.scala
@@ -0,0 +1,18 @@
1
+import scala.quoted._
2
+
3
+object Macro {
4
5
+ extension (inline sc: StringContext):
6
+ inline def x(inline args: Int*): String = ${ code('sc, 'args) }
7
8
+ def code(strCtxExpr: Expr[StringContext], argsExpr: Expr[Seq[Int]])(using QuoteContext): Expr[String] =
9
+ var res: Expr[String] = null
10
+ for _ <- 0 to 5_000 do
11
+ (strCtxExpr, argsExpr) match {
12
+ case ('{ StringContext(${Varargs(Consts(parts))}: _*) }, Varargs(Consts(args))) =>
13
+ res = Expr(StringContext(parts: _*).s(args: _*))
14
+ case _ => ???
15
+ }
16
+ res
17
18
+}
tests/bench/string-interpolation-macro/Test.scala
@@ -0,0 +1,4 @@
+import Macro._
+class Test:
+ def test: String = x"a${1}b${2}c${3}d${4}e${5}f"
0 commit comments