From f8697fd2cd0e234876174df4fa03a2d0da7d4768 Mon Sep 17 00:00:00 2001 From: Jose Antonio Ortega Ruiz Date: Mon, 25 Jan 2010 21:18:07 +0100 Subject: Inconsequential refactoring of Disk. Ignore-this: b1d249892a8a8a44bdbe0dad9e366bcb darcs-hash:20100125201807-1d908-15da5af6614e14470544c5d4439b6bc027b9a0cf.gz --- Plugins/Monitors/Disk.hs | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/Plugins/Monitors/Disk.hs b/Plugins/Monitors/Disk.hs index 6b825d2..76116fb 100644 --- a/Plugins/Monitors/Disk.hs +++ b/Plugins/Monitors/Disk.hs @@ -77,20 +77,15 @@ formatDev path (dev, xs) = in (dev, path, dat) speedToStr :: Int -> Float -> String -speedToStr n x = - let units = ["B", "K", "M", "T"] - toI = round :: Float -> Integer - s y j = y ++ units !! j - in - if n > 2 || x < 103 then - s (show $ toI x) n - else - if x < 1024 then - let (ds, _) = floatToDigits 10 (x / 1024) - tr = if length ds > 1 then show $ ds !! 1 else "0" - in s ("0." ++ show (head ds) ++ tr) (n + 1) - else - speedToStr (n + 1) (x / 1024) +speedToStr n x + | n > 2 || x < 103 = show (rInt x) ++ units !! n + | x < 1024 = "0." ++ s2 ds ++ units !! (n + 1) + | otherwise = speedToStr (n + 1) (x / 1024) + where units = ["B", "K", "M", "T"] + rInt = round :: Float ->Integer + s2 (a:b:_) = show a ++ show b + s2 as = show (head as) ++ "0" + (ds, _) = floatToDigits 10 (x / 1024) runDisk' :: String -> [Float] -> Monitor String runDisk' tmp xs = do -- cgit v1.2.3