[commit: ghc] master: Make GHC.IO.Buffer.summaryBuffer strict (b1e0c65)

git at git.haskell.org git at git.haskell.org
Tue Oct 3 13:45:28 UTC 2017


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/b1e0c65a1302f998917e6d33d6e1ebb84cd09fa8/ghc

>---------------------------------------------------------------

commit b1e0c65a1302f998917e6d33d6e1ebb84cd09fa8
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date:   Mon Oct 2 15:28:35 2017 +0100

    Make GHC.IO.Buffer.summaryBuffer strict
    
    I came across this when debugging something else.  Making it strict
    improves the code slightly without affecting behaviour.


>---------------------------------------------------------------

b1e0c65a1302f998917e6d33d6e1ebb84cd09fa8
 libraries/base/GHC/IO/Buffer.hs | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libraries/base/GHC/IO/Buffer.hs b/libraries/base/GHC/IO/Buffer.hs
index 33eee63..f3cabb2 100644
--- a/libraries/base/GHC/IO/Buffer.hs
+++ b/libraries/base/GHC/IO/Buffer.hs
@@ -1,4 +1,4 @@
-{-# LANGUAGE Trustworthy #-}
+{-# LANGUAGE Trustworthy, BangPatterns #-}
 {-# LANGUAGE CPP, NoImplicitPrelude #-}
 {-# OPTIONS_GHC -funbox-strict-fields #-}
 
@@ -264,7 +264,8 @@ foreign import ccall unsafe "memmove"
    memmove :: Ptr a -> Ptr a -> CSize -> IO (Ptr a)
 
 summaryBuffer :: Buffer a -> String
-summaryBuffer buf = "buf" ++ show (bufSize buf) ++ "(" ++ show (bufL buf) ++ "-" ++ show (bufR buf) ++ ")"
+summaryBuffer !buf  -- Strict => slightly better code
+   = "buf" ++ show (bufSize buf) ++ "(" ++ show (bufL buf) ++ "-" ++ show (bufR buf) ++ ")"
 
 -- INVARIANTS on Buffers:
 --   * r <= w



More information about the ghc-commits mailing list