on master help sign in
Fix efficiency problem with module chasing
d23221bEdwin Brady
src/Idris/Chaser.hs+22−14
@@ -32,9 +32,17 @@ data ModuleTree = MTree { mod_path :: IFileType,
32 mod_deps :: [ModuleTree] }
32 mod_deps :: [ModuleTree] }
33 deriving Show
33 deriving Show
34
34
35−latest :: UTCTime -> [ModuleTree] -> UTCTime
35+latest :: UTCTime -> [IFileType] -> [ModuleTree] -> UTCTime
36−latest tm [] = tm
36+latest tm done [] = tm
37+latest tm done (m : ms)
38+ | mod_path m `elem` done = latest tm done ms
37−latest tm (m : ms) = latest (max tm (mod_time m)) (ms ++ mod_deps m)
39+ | otherwise = latest (max tm (mod_time m)) (mod_path m : done)
40+ (ms ++ mod_deps m)
41+
42+modName :: IFileType -> String
43+modName (IDR fp) = fp
44+modName (LIDR fp) = fp
45+modName (IBC fp src) = modName src
38
46
39-- | Given a module tree, return the list of files to be loaded. If
47-- | Given a module tree, return the list of files to be loaded. If
40-- any module has a descendent which needs reloading, return its
48-- any module has a descendent which needs reloading, return its
@@ -46,17 +54,17 @@ getModuleFiles ts = nub $ execState (modList ts) [] where
46 modList (m : ms) = do modTree [] m; modList ms
54 modList (m : ms) = do modTree [] m; modList ms
47
55
48 modTree path (MTree p rechk tm deps)
56 modTree path (MTree p rechk tm deps)
49− = do let file = chkReload rechk p
57+ = do let file = chkReload rechk p
50− -- Needs rechecking if 'rechk' is true, or if any of the
58+ -- Needs rechecking if 'rechk' is true, or if any of the
51− -- modification times in 'deps' are later than tm
59+ -- modification times in 'deps' are later than tm
52− let depMod = latest tm deps
60+ let depMod = latest tm [] deps
53− let needsRechk = rechk || depMod > tm
61+ let needsRechk = rechk || depMod > tm
54−
62+
55− st <- get
63+ st <- get
56− if needsRechk then put $ nub (getSrc file : updateToSrc path st)
64+ if needsRechk then put $ nub (getSrc file : updateToSrc path st)
57− else put $ nub (file : st)
65+ else put $ nub (file : st)
58−-- when (not (ibc p) || rechk) $
66+ st <- get
59− mapM_ (modTree (getSrc p : path)) deps
67+ mapM_ (modTree (getSrc p : path)) deps
60
68
61 chkReload False p = p
69 chkReload False p = p
62 chkReload True (IBC fn src) = chkReload True src
70 chkReload True (IBC fn src) = chkReload True src
src/Idris/ModeCommon.hs+2−2
@@ -67,8 +67,8 @@ loadInputs inputs toline -- furthest line to read in input source files
67 importlists
67 importlists
68 input
68 input
69 let ifiles = getModuleFiles modTree
69 let ifiles = getModuleFiles modTree
70− logParser 1 ("MODULE TREE : " ++ show modTree)
70+ logParser 2 ("MODULE TREE : " ++ show modTree)
71− logParser 1 ("RELOAD: " ++ show ifiles)
71+ logParser 2 ("RELOAD: " ++ show ifiles)
72 when (not (all ibc ifiles) || loadCode) $
72 when (not (all ibc ifiles) || loadCode) $
73 tryLoad False IBC_Building (filter (not . ibc) ifiles)
73 tryLoad False IBC_Building (filter (not . ibc) ifiles)
74 -- return the files that need rechecking
74 -- return the files that need rechecking