Commit 44ea16e3 by Zachary Snow

ensure, rather than check, traverseScopesM invariant (perf optimization)

parent 04337988
...@@ -977,14 +977,15 @@ traverseScopesM declMapper moduleItemMapper stmtMapper = ...@@ -977,14 +977,15 @@ traverseScopesM declMapper moduleItemMapper stmtMapper =
redirectModuleItem item = redirectModuleItem item =
moduleItemMapper item moduleItemMapper item
-- This previously checked the invariant that the module item mappers
-- should not modify the state. Now we simply "enforce" it but resetting
-- the state to its previous value. Comparing the state, as we did
-- previously, incurs a noticeable performance hit.
fullModuleItemMapper item = do fullModuleItemMapper item = do
prevState <- get prevState <- get
item' <- redirectModuleItem item item' <- redirectModuleItem item
currState <- get put prevState
if prevState == currState return item'
then return item'
else error $ "illegal scope state modification: "
++ show (prevState, item, currState, item')
-- applies the given decl conversion across the description, and then performs a -- applies the given decl conversion across the description, and then performs a
-- scoped traversal for each ModuleItem in the description -- scoped traversal for each ModuleItem in the description
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment