diff options
| author | Tom Smeding <tom@tomsmeding.com> | 2026-05-08 01:04:31 +0200 |
|---|---|---|
| committer | Tom Smeding <tom@tomsmeding.com> | 2026-05-08 01:04:31 +0200 |
| commit | 80ba594a6b44b9693eeaa27bf3bea225a57527ca (patch) | |
| tree | 448e17c7b6a58f1ddc73273c003949c9a80d3ac8 /src/Index.hs | |
| parent | 1446fba192da53cd0f6382b99a53bd1467f98bb6 (diff) | |
Eliminate some thunks
This saves ALL the memory; all files were previously kept in memory
Diffstat (limited to 'src/Index.hs')
| -rw-r--r-- | src/Index.hs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/Index.hs b/src/Index.hs index bdc3751..89a24e3 100644 --- a/src/Index.hs +++ b/src/Index.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE BangPatterns #-} {-# LANGUAGE NumericUnderscores #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ViewPatterns #-} @@ -95,14 +96,15 @@ initIndex basedir toimport = do Nothing -> error $ "Log file with unexpected file name: " ++ path -- atomicPrintS $ "Parsing " ++ path ++ " (" ++ show date ++ " -> " ++ show (dateToDay date) ++ ")" events <- parseLog <$> BS.readFile path - return (uncurry3 fromGregorian date, length events) + let !nevents = length events + return (uncurry3 fromGregorian date, nevents) let minday = minimum (map fst days) maxday = maximum (map fst days) ndays = fromIntegral @Integer @Int (diffDays maxday minday + 1) -- traceM $ nw ++ "/" ++ ch ++ ": days = " ++ show [(toFileName (dayToYMD d), i) | (d, i) <- days] let countScan = IGV.fromListN ndays (drop 1 $ scanl' (+) 0 (makeCounts [minday..maxday] days)) ntotal = sum (map snd days) - chanindex <- newIORef $ + chanindex <- newIORef $! ChanIndex { ciStartDay = minday , ciCountUntil = countScan , ciTotal = ntotal } |
