[commit: ghc] master: cleanup: drop 11 years old performance hack (cdbb9da)
git at git.haskell.org
git at git.haskell.org
Sun Sep 4 21:11:39 UTC 2016
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/cdbb9da7a1330366678c4e29d11a48e591c1ac1e/ghc
>---------------------------------------------------------------
commit cdbb9da7a1330366678c4e29d11a48e591c1ac1e
Author: Sergei Trofimovich <siarheit at google.com>
Date: Sun Sep 4 22:08:27 2016 +0100
cleanup: drop 11 years old performance hack
The 'return () >>' hack was added in commit
commit ac88f113abdec1edbffb6d2f97323e81f82908e7
Date: Tue Jul 26 12:14:03 2005 +0000
Nowadays it has no effect on generated Core on -O1/-O2
and slightly bloats Core on -O0.
Signed-off-by: Sergei Trofimovich <siarheit at google.com>
>---------------------------------------------------------------
cdbb9da7a1330366678c4e29d11a48e591c1ac1e
compiler/utils/Pretty.hs | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)
diff --git a/compiler/utils/Pretty.hs b/compiler/utils/Pretty.hs
index 9849032..5b025d5 100644
--- a/compiler/utils/Pretty.hs
+++ b/compiler/utils/Pretty.hs
@@ -1018,9 +1018,6 @@ hPutLitString handle a l = if l == 0
-- and async exception-safe. We only have a single thread and don't
-- care about exceptions, so we add a layer of fast buffering
-- over the Handle interface.
---
--- (3) a few hacks in layLeft below to convince GHC to generate the right
--- code.
printLeftRender :: Handle -> Doc -> IO ()
printLeftRender hdl doc = do
@@ -1031,14 +1028,11 @@ printLeftRender hdl doc = do
bufLeftRender :: BufHandle -> Doc -> IO ()
bufLeftRender b doc = layLeft b (reduceDoc doc)
--- HACK ALERT! the "return () >>" below convinces GHC to eta-expand
--- this function with the IO state lambda. Otherwise we end up with
--- closures in all the case branches.
layLeft :: BufHandle -> Doc -> IO ()
layLeft b _ | b `seq` False = undefined -- make it strict in b
layLeft _ NoDoc = error "layLeft: NoDoc"
-layLeft b (Union p q) = return () >> layLeft b (first p q)
-layLeft b (Nest _ p) = return () >> layLeft b p
+layLeft b (Union p q) = layLeft b (first p q)
+layLeft b (Nest _ p) = layLeft b p
layLeft b Empty = bPutChar b '\n'
layLeft b (NilAbove p) = bPutChar b '\n' >> layLeft b p
layLeft b (TextBeside s _ p) = put b s >> layLeft b p
More information about the ghc-commits
mailing list