on master help sign in
Merge pull request #3062 from melted/load_less
7a59d10Niklas Larsson
CHANGELOG+6
@@ -1,3 +1,9 @@
1+New in 0.12:
2+============
3+
4+* Improved startup performance by reducing the processing of an already imported
5+ module that has changed accessibility.
6+
1New in 0.11:
7New in 0.11:
2============
8============
3
9
src/Idris/IBC.hs+24−14
@@ -113,23 +113,28 @@ hasValidIBCVersion fp = do
113 Right archive -> do ver <- getEntry 0 "ver" archive
113 Right archive -> do ver <- getEntry 0 "ver" archive
114 return (ver == ibcVersion)
114 return (ver == ibcVersion)
115
115
116+
116loadIBC :: Bool -- ^ True = reexport, False = make everything private
117loadIBC :: Bool -- ^ True = reexport, False = make everything private
117 -> IBCPhase
118 -> IBCPhase
118 -> FilePath -> Idris ()
119 -> FilePath -> Idris ()
119loadIBC reexport phase fp
120loadIBC reexport phase fp
120 = do imps <- getImported
121 = do imps <- getImported
121− let redo = case lookup fp imps of
122+ case lookup fp imps of
122− Nothing -> True
123+ Nothing -> load True
123− Just p -> not p && reexport
124+ Just p -> if (not p && reexport) then load False else return ()
124− when redo $
125+ where
126+ load fullLoad = do
125− do logIBC 1 $ "Loading ibc " ++ fp ++ " " ++ show reexport
127+ logIBC 1 $ "Loading ibc " ++ fp ++ " " ++ show reexport
126− archiveFile <- runIO $ B.readFile fp
128+ archiveFile <- runIO $ B.readFile fp
127− case toArchiveOrFail archiveFile of
129+ case toArchiveOrFail archiveFile of
130+ Left _ -> do
128− Left _ -> ifail $ fp ++ " isn't loadable, it may have an old ibc format.\n"
131+ ifail $ fp ++ " isn't loadable, it may have an old ibc format.\n"
129− ++ "Please clean and rebuild it."
132+ ++ "Please clean and rebuild it."
133+ Right archive -> do
134+ if fullLoad
130− Right archive -> do process reexport phase archive fp
135+ then process reexport phase archive fp
136+ else unhide phase archive
131− addImported reexport fp
137+ addImported reexport fp
132−-- dumpTT
133
138
134-- | Load an entire package from its index file
139-- | Load an entire package from its index file
135loadPkgIndex :: String -> Idris ()
140loadPkgIndex :: String -> Idris ()
@@ -324,8 +329,13 @@ getEntry alt f a = case findEntryByPath f a of
324 Nothing -> return alt
329 Nothing -> return alt
325 Just e -> return $! (force . decode . fromEntry) e
330 Just e -> return $! (force . decode . fromEntry) e
326
331
332+unhide :: IBCPhase -> Archive -> Idris ()
333+unhide phase ar = do
334+ pImports True phase =<< getEntry [] "ibc_imports" ar
335+ pAccess True phase =<< getEntry [] "ibc_access" ar
336+
327process :: Bool -- ^ Reexporting
337process :: Bool -- ^ Reexporting
328− -> IBCPhase
338+ -> IBCPhase
329 -> Archive -> FilePath -> Idris ()
339 -> Archive -> FilePath -> Idris ()
330process reexp phase i fn = do
340process reexp phase i fn = do
331 ver <- getEntry 0 "ver" i
341 ver <- getEntry 0 "ver" i
@@ -616,7 +626,7 @@ pAccess reexp phase ds
616 else logIBC 1 $ "Exporting " ++ show n
626 else logIBC 1 $ "Exporting " ++ show n
617 -- Everything should be available at the REPL from
627 -- Everything should be available at the REPL from
618 -- things imported publicly
628 -- things imported publicly
619− when (phase == IBC_REPL True) $
629+ when (phase == IBC_REPL True) $
620 setAccessibility n Public
630 setAccessibility n Public
621 ) ds
631 ) ds
622
632