From 737aec8c1f31077b1a4e1ada1e33d25c1612fec8 Mon Sep 17 00:00:00 2001 From: Alexander Foremny Date: Tue, 17 Oct 2023 14:54:54 +0200 Subject: inline `cached` into function calls --- app/History.hs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'app') diff --git a/app/History.hs b/app/History.hs index 7ed09bc..002ca32 100644 --- a/app/History.hs +++ b/app/History.hs @@ -40,8 +40,8 @@ listEvents = do case commitHashes of [] -> pure [] hashFirst : hashesRest -> do - issuesInitial <- cached (append hashFirst (pack ".all")) (\_ -> getIssuesCommitAll hashFirst) - commitInfos <- mapM (\hash -> cached (append hash (pack ".changed")) (\_ -> getCommitInfo hash)) hashesRest + issuesInitial <- getIssuesCommitAll hashFirst + commitInfos <- mapM getCommitInfo hashesRest commitInfoWorkingTree <- getCommitInfoWorkingTree [] let eventses = getEvents hashFirst issuesInitial (commitInfos ++ [commitInfoWorkingTree]) pure eventses @@ -67,8 +67,8 @@ listIssues sort filters paths = do -- complete issue text and parse it. -- -- @topic caching - issuesInitial <- cached (append hashFirst (pack ".all")) (\_ -> getIssuesCommitAll hashFirst) - commitInfos <- mapM (\hash -> cached (append hash (pack ".changed")) (\_ -> getCommitInfo hash)) hashesRest + issuesInitial <- getIssuesCommitAll hashFirst + commitInfos <- mapM getCommitInfo hashesRest commitInfoWorkingTree <- getCommitInfoWorkingTree paths let eventses = getEvents hashFirst issuesInitial (commitInfos ++ [commitInfoWorkingTree]) let issues = mapMaybe issueFromIssueEvents eventses @@ -124,7 +124,7 @@ data CommitInfo = CommitInfo deriving (Show, Binary, Generic) getCommitInfo :: Text -> IO CommitInfo -getCommitInfo hash = do +getCommitInfo hash = cached (append hash (pack ".changed")) $ \_ -> do (issuesCommitChanged, filesChanged) <- getIssuesAndFilesCommitChanged hash pure $ CommitInfo @@ -237,7 +237,7 @@ getIssuesAndFilesWorkingTreeChanged paths = do -- [tree](https://git-scm.com/docs/gitglossary#Documentation/gitglossary.txt-aiddeftreeatree) -- of this commit. getIssuesCommitAll :: Text -> IO [Issue] -getIssuesCommitAll hash = do +getIssuesCommitAll hash = cached (append hash (pack ".all")) $ \_ -> do withSystemTempDirectory "history" $ \tmp -> do let cwd = tmp unpack hash Git.withWorkingTree cwd hash do -- cgit v1.2.3