more speed

This commit is contained in:
Simon Michael 2007-07-03 06:16:15 +00:00
parent 78a506e85a
commit b06fe57c00
2 changed files with 6 additions and 3 deletions

View File

@ -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

View File

@ -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