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/History/CommitHash.hs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'app/History/CommitHash.hs') diff --git a/app/History/CommitHash.hs b/app/History/CommitHash.hs index cbe4db1..1075b2f 100644 --- a/app/History/CommitHash.hs +++ b/app/History/CommitHash.hs @@ -6,6 +6,7 @@ module History.CommitHash where import Data.Binary (Binary) +import Data.Maybe (fromMaybe) import Data.Text qualified as T import GHC.Generics (Generic) import Render qualified as P @@ -15,13 +16,12 @@ data CommitHash | Commit T.Text deriving (Eq, Show, Binary, Generic) -toShortText :: CommitHash -> T.Text -toShortText WorkingTree = "" -toShortText (Commit hash) = T.take 7 hash +toShortText :: CommitHash -> Maybe T.Text +toShortText = fmap (T.take 7) . toText -toText :: CommitHash -> T.Text -toText WorkingTree = "" -toText (Commit hash) = hash +toText :: CommitHash -> Maybe T.Text +toText WorkingTree = Nothing +toText (Commit hash) = Just hash instance P.Render CommitHash where render = P.render . P.Detailed @@ -29,9 +29,9 @@ instance P.Render CommitHash where instance P.Render (P.Detailed CommitHash) where render (P.Detailed commitHash) = P.styled [P.color P.Yellow] $ - P.render (toText commitHash) + P.render (fromMaybe "" (toText commitHash)) instance P.Render (P.Summarized CommitHash) where render (P.Summarized commitHash) = P.styled [P.color P.Yellow] $ - P.render (toShortText commitHash) + P.render (fromMaybe "" (toShortText commitHash)) -- cgit v1.2.3