From 2d00b1e5c5097f37ec0a0a9092bb64df040be309 Mon Sep 17 00:00:00 2001 From: Adam Sampson Date: Wed, 7 May 2008 15:51:09 +0000 Subject: [PATCH] Optimise applyX a bit. This avoids computing the transformation function each time we recurse. --- pass/Traversal.hs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pass/Traversal.hs b/pass/Traversal.hs index 587c15d..18d4566 100644 --- a/pass/Traversal.hs +++ b/pass/Traversal.hs @@ -77,13 +77,16 @@ extC info f = extD info (checkToTransform f) -- | Apply a set of transformations. applyX :: Data s => InfoX -> s -> PassM s -applyX info@(tks, g) = g doGeneric doGeneric +applyX info@(tks, maker) = trans where ts :: TypeSet ts = makeTypeSet tks + trans :: Data s => s -> PassM s + trans = maker doGeneric doGeneric + doGeneric :: Data t => t -> PassM t - doGeneric = gmapMFor ts (applyX info) + doGeneric = gmapMFor ts trans -- | Apply a transformation, recursing depth-first. applyDepthM :: forall t1 s. (Data t1, Data s) =>