summaryrefslogtreecommitdiff
path: root/src/compiler/GF/Compile.hs
diff options
context:
space:
mode:
authorhallgren <hallgren@chalmers.se>2011-08-30 18:54:50 +0000
committerhallgren <hallgren@chalmers.se>2011-08-30 18:54:50 +0000
commitba10b5b0ca0c906b1b5c94f64b37b5a34f200f71 (patch)
tree360302c1d8eb917dd650a9df405b3cca504459ab /src/compiler/GF/Compile.hs
parent2001788b0242a0c945655c503262ccf104bcc3bd (diff)
GF.Infra.Modules: keep the modules of a grammar in a finite map instead of a list
This speeds up the compilation of PhrasebookFin.pgf by 12%, mosly by speeding up calls to lookupModule in calls from lookupParamValues, in calls from allParamValues. The invariant "modules are stored in dependency order" is no longer respected! But the type MGrammar is now abstract, making it easier to maintain this or other invariants in the future.
Diffstat (limited to 'src/compiler/GF/Compile.hs')
-rw-r--r--src/compiler/GF/Compile.hs10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/compiler/GF/Compile.hs b/src/compiler/GF/Compile.hs
index 00b08dbf3..b0c228e53 100644
--- a/src/compiler/GF/Compile.hs
+++ b/src/compiler/GF/Compile.hs
@@ -69,8 +69,8 @@ batchCompile opts files = do
-- to compile a set of modules, e.g. an old GF or a .cf file
compileSourceGrammar :: Options -> SourceGrammar -> IOE SourceGrammar
-compileSourceGrammar opts gr@(MGrammar ms) = do
- (_,gr',_) <- foldM compOne (0,emptySourceGrammar,Map.empty) ms
+compileSourceGrammar opts gr = do
+ (_,gr',_) <- foldM compOne (0,emptySourceGrammar,Map.empty) (modules gr)
return gr'
where
compOne env mo = do
@@ -215,19 +215,19 @@ generateModuleCode opts file minfo = do
-- auxiliaries
-reverseModules (MGrammar ms) = MGrammar $ reverse ms
+--reverseModules (MGrammar ms) = MGrammar $ reverse ms
emptyCompileEnv :: CompileEnv
emptyCompileEnv = (0,emptyMGrammar,Map.empty)
-extendCompileEnvInt (_,MGrammar ss,menv) k mfile sm = do
+extendCompileEnvInt (_,gr,menv) k mfile sm = do
let (mod,imps) = importsOfModule sm
menv2 <- case mfile of
Just file -> do
t <- ioeIO $ getModificationTime file
return $ Map.insert mod (t,imps) menv
_ -> return menv
- return (k,MGrammar (sm:ss),menv2) --- reverse later
+ return (k,mGrammar (sm:modules gr),menv2) --- reverse later
extendCompileEnv e@(k,_,_) file sm = extendCompileEnvInt e k (Just file) sm