[commit: ghc] master: Be sure to UNPACK the size of an array (98aab76)

git at git.haskell.org git at git.haskell.org
Thu Apr 24 07:43:57 UTC 2014


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

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

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

commit 98aab76a5498b003635fd78188b7c1e3623c73d5
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date:   Tue Apr 22 14:37:22 2014 +0100

    Be sure to UNPACK the size of an array
    
    The code before did actually unpack the size, I think, but it
    wasn't very clear, and it's better to do it explicitly


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

98aab76a5498b003635fd78188b7c1e3623c73d5
 libraries/base/GHC/Arr.lhs |   18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/libraries/base/GHC/Arr.lhs b/libraries/base/GHC/Arr.lhs
index 0235624..6d11e38 100644
--- a/libraries/base/GHC/Arr.lhs
+++ b/libraries/base/GHC/Arr.lhs
@@ -381,12 +381,12 @@ instance  (Ix a1, Ix a2, Ix a3, Ix a4, Ix a5) => Ix (a1,a2,a3,a4,a5)  where
 -- | The type of immutable non-strict (boxed) arrays
 -- with indices in @i@ and elements in @e at .
 data Array i e
-         = Array !i         -- the lower bound, l
-                 !i         -- the upper bound, u
-                 !Int       -- a cache of (rangeSize (l,u))
-                            -- used to make sure an index is
-                            -- really in range
-                 (Array# e) -- The actual elements
+   = Array            !i         -- the lower bound, l
+                      !i         -- the upper bound, u
+       {-# UNPACK #-} !Int       -- A cache of (rangeSize (l,u))
+                                 -- used to make sure an index is
+                                 -- really in range
+                      (Array# e) -- The actual elements
 
 -- | Mutable, boxed, non-strict arrays in the 'ST' monad.  The type
 -- arguments are as follows:
@@ -398,9 +398,9 @@ data Array i e
 --  * @e@: the element type of the array.
 --
 data STArray s i e
-         = STArray !i                  -- the lower bound, l
-                   !i                  -- the upper bound, u
-                   !Int                -- a cache of (rangeSize (l,u))
+  = STArray           !i               -- the lower bound, l
+                      !i               -- the upper bound, u
+      {-# UNPACK #-}  !Int             -- A cache of (rangeSize (l,u))
                                        -- used to make sure an index is
                                        -- really in range
                    (MutableArray# s e) -- The actual elements



More information about the ghc-commits mailing list