Skip to content

Commit a9867e0

Browse files
committed
Precompute initial NXTransformations in TreeTransforms.
Helps Annotation transformers which do not need to reinitialise themselves anymore.
1 parent 56cad14 commit a9867e0

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/dotty/tools/dotc/transform/TreeTransform.scala

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -547,12 +547,16 @@ object TreeTransforms {
547547
val prepForStats: Mutator[List[Tree]] = (trans, trees, ctx) => trans.prepareForStats(trees)(ctx)
548548
val prepForUnit: Mutator[Tree] = (trans, tree, ctx) => trans.prepareForUnit(tree)(ctx)
549549

550+
val initialTransformationsCache = transformations.zipWithIndex.map {
551+
case (transform, id) =>
552+
transform.idx = id
553+
transform
554+
}
555+
556+
val initialInfoCache = new TransformerInfo(initialTransformationsCache, new NXTransformations(initialTransformationsCache), this)
557+
550558
def macroTransform(t: Tree)(implicit ctx: Context): Tree = {
551-
val initialTransformations = transformations
552-
val info = new TransformerInfo(initialTransformations, new NXTransformations(initialTransformations), this)
553-
initialTransformations.zipWithIndex.foreach {
554-
case (transform, id) => transform.idx = id
555-
}
559+
val info = initialInfoCache
556560
implicit val mutatedInfo: TransformerInfo = mutateTransformers(info, prepForUnit, info.nx.nxPrepUnit, t, 0)
557561
if (mutatedInfo eq null) t
558562
else goUnit(transform(t, mutatedInfo, 0), mutatedInfo.nx.nxTransUnit(0))

0 commit comments

Comments
 (0)