[commit: ghc] master: Pretty: use replicate for spaces and multi_ch (#10735) (85179b5)
git at git.haskell.org
git at git.haskell.org
Wed Aug 5 08:11:12 UTC 2015
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/85179b5821bb1010eede7cec43280c2cd7e59bd3/ghc
>---------------------------------------------------------------
commit 85179b5821bb1010eede7cec43280c2cd7e59bd3
Author: Thomas Miedema <thomasmiedema at gmail.com>
Date: Tue Aug 4 18:32:09 2015 +0200
Pretty: use replicate for spaces and multi_ch (#10735)
Similar changes were made to pretty in commit
7575ab16430c876eaa1451b02465b6b103b3a519.
>---------------------------------------------------------------
85179b5821bb1010eede7cec43280c2cd7e59bd3
compiler/utils/Pretty.hs | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/compiler/utils/Pretty.hs b/compiler/utils/Pretty.hs
index 741c931..0bde5fa 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 "")
More information about the ghc-commits
mailing list