summaryrefslogtreecommitdiff
path: root/utils/hpc/HpcMarkup.hs
diff options
context:
space:
mode:
authorAustin Seipp <austin@well-typed.com>2014-10-02 14:51:34 -0500
committerAustin Seipp <austin@well-typed.com>2014-10-02 14:51:34 -0500
commitd6d5c127b86dc186b25add2843cb83fc12e72a85 (patch)
tree7d6e4bc542f775fa6ad413186df9fad5941db1d3 /utils/hpc/HpcMarkup.hs
parent35672072b4091d6f0031417bc160c568f22d0469 (diff)
downloadhaskell-d6d5c127b86dc186b25add2843cb83fc12e72a85.tar.gz
Revert "Use dropWhileEndLE p instead of reverse . dropWhile p . reverse"
This reverts commit 2a8856884de7d476e26b4ffa829ccb3a14d6f63e.
Diffstat (limited to 'utils/hpc/HpcMarkup.hs')
-rw-r--r--utils/hpc/HpcMarkup.hs25
1 files changed, 6 insertions, 19 deletions
diff --git a/utils/hpc/HpcMarkup.hs b/utils/hpc/HpcMarkup.hs
index c294b6a94e..8fd9e4226c 100644
--- a/utils/hpc/HpcMarkup.hs
+++ b/utils/hpc/HpcMarkup.hs
@@ -140,16 +140,6 @@ charEncodingTag =
"<meta http-equiv=\"Content-Type\" " ++
"content=\"text/html; " ++ "charset=" ++ show localeEncoding ++ "\">"
--- Add characters to the left of a string until it is at least as
--- large as requested.
-padLeft :: Int -> Char -> String -> String
-padLeft n c str = go n str
- where
- -- If the string is already long enough, stop traversing it.
- go 0 _ = str
- go k [] = replicate k c ++ str
- go k (_:xs) = go (k-1) xs
-
genHtmlFromMod
:: String
-> Flags
@@ -220,7 +210,8 @@ genHtmlFromMod dest_dir flags tix theFunTotals invertOutput = do
content <- readFileFromPath (hpcError markup_plugin) origFile theHsPath
let content' = markup tabStop info content
- let addLine n xs = "<span class=\"lineno\">" ++ padLeft 5 ' ' (show n) ++ " </span>" ++ xs
+ let show' = reverse . take 5 . (++ " ") . reverse . show
+ let addLine n xs = "<span class=\"lineno\">" ++ show' n ++ " </span>" ++ xs
let addLines = unlines . map (uncurry addLine) . zip [1 :: Int ..] . lines
let fileName = modName0 ++ ".hs.html"
putStrLn $ "Writing: " ++ fileName
@@ -372,14 +363,10 @@ openTick (TopLevelDecl True 1)
openTick (TopLevelDecl True n0)
= "<span class=\"funcount\">-- entered " ++ showBigNum n0 ++ " times</span>" ++ openTopDecl
where showBigNum n | n <= 9999 = show n
- | otherwise = case n `quotRem` 1000 of
- (q, r) -> showBigNum' q ++ "," ++ showWith r
+ | otherwise = showBigNum' (n `div` 1000) ++ "," ++ showWith (n `mod` 1000)
showBigNum' n | n <= 999 = show n
- | otherwise = case n `quotRem` 1000 of
- (q, r) -> showBigNum' q ++ "," ++ showWith r
- showWith n = padLeft 3 '0' $ show n
-
-
+ | otherwise = showBigNum' (n `div` 1000) ++ "," ++ showWith (n `mod` 1000)
+ showWith n = take 3 $ reverse $ ("000" ++) $ reverse $ show n
closeTick :: String
closeTick = "</span>"
@@ -475,7 +462,7 @@ instance Monoid ModuleSummary where
writeFileUsing :: String -> String -> IO ()
writeFileUsing filename text = do
- let dest_dir = dropWhileEndLE (\ x -> x /= '/') $ filename
+ let dest_dir = reverse . dropWhile (\ x -> x /= '/') . reverse $ filename
-- We need to check for the dest_dir each time, because we use sub-dirs for
-- packages, and a single .tix file might contain information about