summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJose Antonio Ortega Ruiz <jao@gnu.org>2010-12-19 05:05:47 +0100
committerJose Antonio Ortega Ruiz <jao@gnu.org>2010-12-19 05:05:47 +0100
commit35944478a10cee4bf5da299b8450f82f0177b655 (patch)
treed3e7ac1d11f511e0a740916bc62c12afb6c1154d
parentaf032b8b70c1f5a71a919bbbc96682bae0c1b097 (diff)
downloadxmobar-35944478a10cee4bf5da299b8450f82f0177b655.tar.gz
xmobar-35944478a10cee4bf5da299b8450f82f0177b655.tar.bz2
Idle refactoring
-rw-r--r--Plugins/Monitors/Top.hs19
1 files changed, 8 insertions, 11 deletions
diff --git a/Plugins/Monitors/Top.hs b/Plugins/Monitors/Top.hs
index e83e94b..6af22e3 100644
--- a/Plugins/Monitors/Top.hs
+++ b/Plugins/Monitors/Top.hs
@@ -127,17 +127,16 @@ timeMemEntries :: IO [(TimeEntry, Meminfo)]
timeMemEntries = handleProcesses timeMemEntry
timeMemInfos :: IO (Times, [Meminfo], Int)
-timeMemInfos =
- fmap (\x -> (sortPids $ map fst x, map snd x, length x)) timeMemEntries
- where sortPids = sortBy (comparing fst)
+timeMemInfos = fmap res timeMemEntries
+ where res x = (sortBy (comparing fst) $ map fst x, map snd x, length x)
combine :: Times -> Times -> Times
combine _ [] = []
-combine [] t = t
-combine l@((p0, (n0, t0)):xs) r@((p1, (n1, t1)):ys)
- | p0 == p1 = (p0, (n0, t1 - t0)) : combine xs ys
- | p0 < p1 = combine xs r
- | otherwise = (p1, (n1, t1)) : combine l ys
+combine [] ts = ts
+combine l@((p0, (n0, t0)):ls) r@((p1, (n1, t1)):rs)
+ | p0 == p1 = (p0, (n0, t1 - t0)) : combine ls rs
+ | p0 < p1 = combine ls r
+ | otherwise = (p1, (n1, t1)) : combine l rs
topProcesses :: TimesRef -> Float -> IO (Int, [TimeInfo], [Meminfo])
topProcesses tref scale = do
@@ -161,9 +160,7 @@ runTop tref scale _ = do
(no, ps, ms) <- io $ topProcesses tref scale
pstr <- mapM showTimeInfo ps
mstr <- showMeminfos ms
- let !pstr' = take maxEntries pstr
- !mstr' = take maxEntries mstr
- parseTemplate $! show no : concat (zipWith (++) pstr' mstr')
+ parseTemplate $ show no : concat (zipWith (++) pstr mstr) ++ repeat "N/A"
startTop :: [String] -> Int -> (String -> IO ()) -> IO ()
startTop a r cb = do