mirror of
https://github.com/simonmichael/hledger.git
synced 2024-11-08 07:09:28 +03:00
more speed
This commit is contained in:
parent
78a506e85a
commit
b06fe57c00
@ -16,7 +16,7 @@ import RawLedger
|
||||
cacheLedger :: RawLedger -> Ledger
|
||||
cacheLedger l =
|
||||
let
|
||||
ant = trace "caching" $ rawLedgerAccountNameTree l
|
||||
ant = rawLedgerAccountNameTree l
|
||||
ans = flatten ant
|
||||
ts = rawLedgerTransactions l
|
||||
sortedts = sortBy (comparing account) ts
|
||||
@ -24,8 +24,11 @@ cacheLedger l =
|
||||
tmap = Map.union
|
||||
(Map.fromList [(account $ head g, g) | g <- groupedts])
|
||||
(Map.fromList [(a,[]) | a <- ans])
|
||||
txns a = tmap ! a
|
||||
subaccts a = filter (isAccountNamePrefixOf a) ans
|
||||
subtxns a = concat [txns a | a <- [a] ++ subaccts a]
|
||||
bmap = Map.union
|
||||
(Map.fromList [(a, sumEntryTransactions $ transactionsWithOrBelowAccountName a ts) | a <- ans])
|
||||
(Map.fromList [(a, sumEntryTransactions $ subtxns a) | a <- ans])
|
||||
(Map.fromList [(a,nullamt) | a <- ans])
|
||||
amap = Map.fromList [(a, Account a (tmap ! a) (bmap ! a)) | a <- ans]
|
||||
in
|
||||
|
@ -65,7 +65,7 @@ selftest = do
|
||||
|
||||
doWithLedger :: [Flag] -> (Ledger -> IO ()) -> IO ()
|
||||
doWithLedger opts cmd = do
|
||||
ledgerFilePath opts >>= (trace "parsing" $ parseLedgerFile) >>= doWithParsed cmd
|
||||
ledgerFilePath opts >>= parseLedgerFile >>= doWithParsed cmd
|
||||
|
||||
doWithParsed :: (Ledger -> IO ()) -> (Either ParseError RawLedger) -> IO ()
|
||||
doWithParsed cmd parsed = do
|
||||
|
Loading…
Reference in New Issue
Block a user