more speed
This commit is contained in:
		
							parent
							
								
									78a506e85a
								
							
						
					
					
						commit
						b06fe57c00
					
				| @ -16,7 +16,7 @@ import RawLedger | |||||||
| cacheLedger :: RawLedger -> Ledger | cacheLedger :: RawLedger -> Ledger | ||||||
| cacheLedger l =  | cacheLedger l =  | ||||||
|     let  |     let  | ||||||
|         ant = trace "caching" $ rawLedgerAccountNameTree l |         ant = rawLedgerAccountNameTree l | ||||||
|         ans = flatten ant |         ans = flatten ant | ||||||
|         ts = rawLedgerTransactions l |         ts = rawLedgerTransactions l | ||||||
|         sortedts = sortBy (comparing account) ts |         sortedts = sortBy (comparing account) ts | ||||||
| @ -24,8 +24,11 @@ cacheLedger l = | |||||||
|         tmap = Map.union  |         tmap = Map.union  | ||||||
|                (Map.fromList [(account $ head g, g) | g <- groupedts]) |                (Map.fromList [(account $ head g, g) | g <- groupedts]) | ||||||
|                (Map.fromList [(a,[]) | a <- ans]) |                (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  |         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]) |                (Map.fromList [(a,nullamt) | a <- ans]) | ||||||
|         amap = Map.fromList [(a, Account a (tmap ! a) (bmap ! a)) | a <- ans] |         amap = Map.fromList [(a, Account a (tmap ! a) (bmap ! a)) | a <- ans] | ||||||
|     in |     in | ||||||
|  | |||||||
| @ -65,7 +65,7 @@ selftest = do | |||||||
| 
 | 
 | ||||||
| doWithLedger :: [Flag] -> (Ledger -> IO ()) -> IO () | doWithLedger :: [Flag] -> (Ledger -> IO ()) -> IO () | ||||||
| doWithLedger opts cmd = do | doWithLedger opts cmd = do | ||||||
|     ledgerFilePath opts >>= (trace "parsing" $ parseLedgerFile) >>= doWithParsed cmd |     ledgerFilePath opts >>= parseLedgerFile >>= doWithParsed cmd | ||||||
| 
 | 
 | ||||||
| doWithParsed :: (Ledger -> IO ()) -> (Either ParseError RawLedger) -> IO () | doWithParsed :: (Ledger -> IO ()) -> (Either ParseError RawLedger) -> IO () | ||||||
| doWithParsed cmd parsed = do | doWithParsed cmd parsed = do | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user