assistant: Fixed several minor memory leaks that manifested when adding a large number of files.

This commit is contained in:
Joey Hess 2014-01-05 21:30:48 -04:00
parent 404c750489
commit b92b54bd42
9 changed files with 39 additions and 19 deletions

View file

@ -5,7 +5,7 @@
- Licensed under the GNU GPL version 3 or higher.
-}
{-# LANGUAGE OverloadedStrings, CPP #-}
{-# LANGUAGE OverloadedStrings, CPP, BangPatterns #-}
module Assistant.Alert where
@ -367,8 +367,8 @@ fileAlert msg files = (activityAlert Nothing shortfiles)
where
maxfilesshown = 10
(somefiles, counter) = splitcounter (dedupadjacent files)
shortfiles = map (fromString . shortFile . takeFileName) somefiles
(!somefiles, !counter) = splitcounter (dedupadjacent files)
!shortfiles = map (fromString . shortFile . takeFileName) somefiles
renderer alert = tenseWords $ msg : alertData alert ++ showcounter
where
@ -391,9 +391,9 @@ fileAlert msg files = (activityAlert Nothing shortfiles)
in (keep, length rest)
combiner new old =
let (fs, n) = splitcounter $
let (!fs, n) = splitcounter $
dedupadjacent $ alertData new ++ alertData old
cnt = n + alertCounter new + alertCounter old
!cnt = n + alertCounter new + alertCounter old
in old
{ alertData = fs
, alertCounter = cnt