From 3c05d0cbd310af1c34d3731a15feb2a9508aded2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Fri, 15 Jul 2022 20:12:09 +0200 Subject: Stored roots with caching --- src/Storage.hs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'src/Storage.hs') diff --git a/src/Storage.hs b/src/Storage.hs index 84df213..cc2476f 100644 --- a/src/Storage.hs +++ b/src/Storage.hs @@ -115,13 +115,25 @@ openStorage path = do createDirectoryIfMissing True $ path ++ "/heads" watchers <- newMVar ([], WatchList 1 []) refgen <- newMVar =<< HT.new - return $ Storage { stBacking = StorageDir path watchers, stParent = Nothing, stRefGeneration = refgen } + refroots <- newMVar =<< HT.new + return $ Storage + { stBacking = StorageDir path watchers + , stParent = Nothing + , stRefGeneration = refgen + , stRefRoots = refroots + } memoryStorage' :: IO (Storage' c') memoryStorage' = do backing <- StorageMemory <$> newMVar [] <*> newMVar M.empty <*> newMVar M.empty <*> newMVar (WatchList 1 []) refgen <- newMVar =<< HT.new - return $ Storage { stBacking = backing, stParent = Nothing, stRefGeneration = refgen } + refroots <- newMVar =<< HT.new + return $ Storage + { stBacking = backing + , stParent = Nothing + , stRefGeneration = refgen + , stRefRoots = refroots + } memoryStorage :: IO Storage memoryStorage = memoryStorage' -- cgit v1.2.3