diff options
author | Joey Hess <joey@kitenet.net> | 2011-09-28 02:46:54 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2011-09-28 02:46:54 -0400 |
commit | d7d9e9aca08b752cc2e04809edc654be39413665 (patch) | |
tree | 058707bbc13843935475b0ef7803f02b49eb294d /PresenceLog.hs | |
parent | 1c9c9a0cee33b63e9147863b95e570a8cc349304 (diff) |
use a foldr
Should be faster here.
Diffstat (limited to 'PresenceLog.hs')
-rw-r--r-- | PresenceLog.hs | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/PresenceLog.hs b/PresenceLog.hs index 5828f76af..7742651b8 100644 --- a/PresenceLog.hs +++ b/PresenceLog.hs @@ -26,7 +26,7 @@ module PresenceLog ( import Data.Time.Clock.POSIX import Data.Time import System.Locale -import qualified Data.Map as Map +import qualified Data.Map as M import Control.Monad.State (liftIO) import Control.Applicative @@ -111,18 +111,18 @@ filterPresent = filter (\l -> InfoPresent == status l) . compactLog {- Compacts a set of logs, returning a subset that contains the current - status. -} compactLog :: [LogLine] -> [LogLine] -compactLog = Map.elems . foldl mapLog Map.empty +compactLog = M.elems . foldr mapLog M.empty -type LogMap = Map.Map String LogLine +type LogMap = M.Map String LogLine {- Inserts a log into a map of logs, if the log has better (ie, newer) - information than the other logs in the map -} -mapLog :: LogMap -> LogLine -> LogMap -mapLog m l = +mapLog :: LogLine -> LogMap -> LogMap +mapLog l m = if better - then Map.insert i l m + then M.insert i l m else m where - better = maybe True newer $ Map.lookup i m + better = maybe True newer $ M.lookup i m newer l' = date l' <= date l i = info l |