From 3c6e62b75293b6625509ade3c278fc2d4d147c30 Mon Sep 17 00:00:00 2001 From: Alexander Foremny Date: Thu, 7 Dec 2023 03:55:45 +0100 Subject: chore: increase performance by caching everything Initial cache generation is slower, as we are losing out on parallelism. --- app/Main.hs | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'app/Main.hs') diff --git a/app/Main.hs b/app/Main.hs index df63624..fe802ad 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -353,7 +353,7 @@ import Data.Text qualified as T import Data.Text.IO qualified as T import Data.Text.Lazy qualified as LT import Data.Text.Lazy.IO qualified as LT -import History (getHistory) +import History (History (..), getHistory) import Issue (Issue (..)) import Issue qualified as I import Issue.Filter qualified as I @@ -517,7 +517,10 @@ idArg = O.strArgument ( O.metavar "ID" <> O.completer - (O.listIOCompleter $ map (T.unpack . I.id) . (._3) . last <$> getHistory) + ( O.listIOCompleter $ + map (T.unpack . I.id) . (.issues) + <$> getHistory + ) ) editFlag :: O.Parser Bool @@ -550,8 +553,7 @@ main = do . I.applyFilters filters . I.applyPath files . I.applyClosed closed - . (._3) - . last + . (.issues) <$> getHistory let groupedIssues = I.groupIssuesByTag group ungroupedIssues putDoc colorize noPager width (group, groupedIssues) @@ -561,28 +563,26 @@ main = do . I.applyFilters filters . I.applyPath files . I.applyClosed closed - . (._3) - . last + . (.issues) <$> getHistory putDoc colorize noPager width . (P.vsep . intersperse "") $ map (P.render . P.Summarized) issues Options {colorize, noPager, width, command = Log {patch}} -> do - ess <- concatMap (._2) . reverse <$> getHistory + es <- reverse . (.issueEvents) <$> getHistory putDoc colorize noPager width . P.vsep $ if patch - then map (P.render . P.Detailed) ess - else map (P.render . P.Summarized) ess + then map (P.render . P.Detailed) es + else map (P.render . P.Summarized) es Options {colorize, noPager, width, command = Show {id = Nothing}} -> do issues <- I.applySorts [] . I.applyFilters [] . I.applyClosed False - . (._3) - . last + . (.issues) <$> getHistory putDoc colorize noPager width . P.vsep $ map (showIssue issues) issues Options {colorize, noPager, width, command = Show {id = Just id, edit}} -> do - issues <- (._3) . last <$> getHistory + issues <- (.issues) <$> getHistory issue <- case find ((==) id . T.unpack . I.id) issues of Nothing -> die (printf "no issue with id `%s'\n" id) @@ -597,7 +597,7 @@ main = do I.replaceText issue =<< T.readFile fp else putDoc colorize noPager width $ showIssue issues issue Options {colorize, noPager, width, internalTags, command = Tags} -> do - issues <- (._3) . last <$> getHistory + issues <- (.issues) <$> getHistory let tags = concatMap ( \issue -> -- cgit v1.2.3