[commit: packages/base] master: Add shiftR and shiftL implementations to instance Bits Integer (f7a7b58)

git at git.haskell.org git at git.haskell.org
Thu Mar 13 12:26:47 UTC 2014


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

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

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

commit f7a7b586bc89ca7fd56792da4172bd93a2acdae9
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date:   Thu Mar 13 12:11:01 2014 +0000

    Add shiftR and shiftL implementations to instance Bits Integer
    
    Apart from simply making sense (avoid the conditional in 'shift'),
    this makes left and right shifts on Integer more likely to inline
    (plain 'shift' is just too large); and this in turn is important
    when fixing the Integer case of #8832


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

f7a7b586bc89ca7fd56792da4172bd93a2acdae9
 Data/Bits.hs |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/Data/Bits.hs b/Data/Bits.hs
index 28cd024..81b180b 100644
--- a/Data/Bits.hs
+++ b/Data/Bits.hs
@@ -437,6 +437,9 @@ instance Bits Integer where
    complement = complementInteger
    shift x i@(I# i#) | i >= 0    = shiftLInteger x i#
                      | otherwise = shiftRInteger x (negateInt# i#)
+   shiftL x (I# i#) = shiftLInteger x i#
+   shiftR x (I# i#) = shiftRInteger x i#
+
    testBit x (I# i) = testBitInteger x i
 
    zeroBits   = 0



More information about the ghc-commits mailing list