mirror of
https://github.com/simonmichael/hledger.git
synced 2024-11-08 07:09:28 +03:00
ref: performance: Use a Set in accountNamesFromPostings, instead of
nubSort. This has better performance when there is repetition in the account names.
This commit is contained in:
parent
ab5350e02c
commit
d55ce4d759
@ -72,11 +72,11 @@ where
|
|||||||
|
|
||||||
import Control.Monad (foldM)
|
import Control.Monad (foldM)
|
||||||
import Data.Foldable (asum)
|
import Data.Foldable (asum)
|
||||||
import Data.List.Extra (nubSort)
|
|
||||||
import qualified Data.Map as M
|
import qualified Data.Map as M
|
||||||
import Data.Maybe (fromMaybe, isJust)
|
import Data.Maybe (fromMaybe, isJust)
|
||||||
import Data.MemoUgly (memo)
|
import Data.MemoUgly (memo)
|
||||||
import Data.List (foldl')
|
import Data.List (foldl')
|
||||||
|
import qualified Data.Set as S
|
||||||
import Data.Text (Text)
|
import Data.Text (Text)
|
||||||
import qualified Data.Text as T
|
import qualified Data.Text as T
|
||||||
import Data.Time.Calendar (Day)
|
import Data.Time.Calendar (Day)
|
||||||
@ -191,7 +191,7 @@ hasBalanceAssignment p = not (hasAmount p) && isJust (pbalanceassertion p)
|
|||||||
|
|
||||||
-- | Sorted unique account names referenced by these postings.
|
-- | Sorted unique account names referenced by these postings.
|
||||||
accountNamesFromPostings :: [Posting] -> [AccountName]
|
accountNamesFromPostings :: [Posting] -> [AccountName]
|
||||||
accountNamesFromPostings = nubSort . map paccount
|
accountNamesFromPostings = S.toList . S.fromList . map paccount
|
||||||
|
|
||||||
-- | Sum all amounts from a list of postings.
|
-- | Sum all amounts from a list of postings.
|
||||||
sumPostings :: [Posting] -> MixedAmount
|
sumPostings :: [Posting] -> MixedAmount
|
||||||
|
Loading…
Reference in New Issue
Block a user