summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Miedema <thomasmiedema@gmail.com>2015-08-04 18:32:09 +0200
committerThomas Miedema <thomasmiedema@gmail.com>2015-08-05 10:10:33 +0200
commit85179b5821bb1010eede7cec43280c2cd7e59bd3 (patch)
tree4f9db93686b21a2f174a0f49bc94911358d56578
parentf951ffc6e4aa8fad1f5dcb6fd013340bf792f92d (diff)
downloadhaskell-85179b5821bb1010eede7cec43280c2cd7e59bd3.tar.gz
Pretty: use replicate for spaces and multi_ch (#10735)
Similar changes were made to pretty in commit 7575ab16430c876eaa1451b02465b6b103b3a519.
-rw-r--r--compiler/utils/Pretty.hs11
1 files changed, 3 insertions, 8 deletions
diff --git a/compiler/utils/Pretty.hs b/compiler/utils/Pretty.hs
index 741c93169d..0bde5fa1c0 100644
--- a/compiler/utils/Pretty.hs
+++ b/compiler/utils/Pretty.hs
@@ -430,8 +430,7 @@ isEmpty _ = False
--
-- an old version inserted tabs being 8 columns apart in the output.
spaces :: Int -> String
-spaces !n | n <= 0 = ""
- | otherwise = ' ' : spaces (n - 1)
+spaces !n = replicate n ' '
{-
Q: What is the reason for negative indentation (i.e. argument to indent
@@ -1000,13 +999,13 @@ display m !page_width !ribbon_width txt end doc
= case m of
ZigZagMode | k >= gap_width
-> nlText `txt` (
- Str (multi_ch shift '/') `txt` (
+ Str (replicate shift '/') `txt` (
nlText `txt`
lay1 (k - shift) s sl p ))
| k < 0
-> nlText `txt` (
- Str (multi_ch shift '\\') `txt` (
+ Str (replicate shift '\\') `txt` (
nlText `txt`
lay1 (k + shift) s sl p ))
@@ -1037,10 +1036,6 @@ display m !page_width !ribbon_width txt end doc
lay 0 doc
}}
-multi_ch :: Int -> Char -> String
-multi_ch !n ch | n <= 0 = ""
- | otherwise = ch : multi_ch (n - 1) ch
-
printDoc :: Mode -> Int -> Handle -> Doc -> IO ()
-- printDoc adds a newline to the end
printDoc mode cols hdl doc = printDoc_ mode cols hdl (doc $$ text "")