on master help sign in
Count inlinable defs when building module hash

This also needs to account for hashes of public imports, so while it's still not quite right it massively speeds up working with larger programs.

commitf445c51466375a0d2e7d58b4d91bac466e7123e2 authorEdwin Brady <ecb10@st-andrews.ac.uk> dateSun 6 Jan 2019, 17:05 (8 years ago) parent1980f49
1 file changed+13−2
src/Idris/IBC.hs+13−2
src/Idris/IBC.hs+13−2
@@ -265,8 +265,9 @@ hashName i n = qhash (i * 5381) (show n)
265265
266266calculateHash :: IState -> IBCFile -> Int
267267calculateHash ist f
268− = let acc = L.filter exported (ibc_access f) in
269− mkHashFrom (map fst acc) (getDefs acc)
268+ = let acc = L.filter exported (ibc_access f)
269+ inl = L.filter (inlinable (map fst acc)) (ibc_flags f) in
270+ mkHashFrom (map fst acc) (getDefs acc ++ L.concatMap getFullDef inl)
270271 where
271272 mkHashFrom :: [Name] -> [Term] -> Int
272273 mkHashFrom ns tms = sum (L.zipWith hashName [1..] ns) +
@@ -276,6 +277,10 @@ calculateHash ist f
276277 exported (_, Frozen) = True
277278 exported _ = False
278279
280+ inlinable acc (n, opts)
281+ = n `elem` acc &&
282+ (Inlinable `elem` opts || PEGenerated `elem` opts)
283+
279284 findTms :: [(a, Term, Term)] -> [Term]
280285 findTms = L.concatMap (\ (_, x, y) -> [x, y])
281286
@@ -299,6 +304,12 @@ calculateHash ist f
299304 Just ty -> ty : ts
300305 getDefs (_ : ns) = getDefs ns
301306
307+ getFullDef :: (Name, [FnOpt]) -> [Term]
308+ getFullDef (n, _)
309+ = case lookupTyExact n (tt_ctxt ist) of
310+ Nothing -> []
311+ Just ty -> ty : patDef n
312+
302313-- | Write a package index containing all the imports in the current
303314-- IState Used for ':search' of an entire package, to ensure
304315-- everything is loaded.