Skip to content

Commit 78771ce

Browse files
committed
Eval: addStackFrames: nodge GHC to optimize it
From my test, ~ a quarter of savings.
1 parent fab166d commit 78771ce

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/Nix/Eval.hs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -509,9 +509,14 @@ addStackFrames
509509
:: forall v e m a
510510
. (Scoped v m, Framed e m, Typeable v, Typeable m)
511511
=> Transform NExprLocF (m a)
512-
addStackFrames f v = do
513-
scopes <- currentScopes :: m (Scopes m v)
514-
withFrame Info (EvaluatingExpr scopes v) (f v)
512+
addStackFrames f v =
513+
do
514+
scopes <- currentScopes :: m (Scopes m v)
515+
516+
-- sectioning gives GHC optimization
517+
(`withFrameInfo` f v) $ (`EvaluatingExpr` v) scopes
518+
where
519+
withFrameInfo = withFrame Info
515520

516521
framedEvalExprLoc
517522
:: forall e v m

src/Nix/Utils.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ adiM
125125
adiM f g = g ((f <=< traverse (adiM f g)) . unFix)
126126

127127
class Has a b where
128-
hasLens :: Lens' a b
128+
hasLens :: Lens' a b
129129

130130
instance Has a a where
131131
hasLens f = f

0 commit comments

Comments
 (0)