summaryrefslogtreecommitdiff
path: root/libraries/base/Data/Bits.hs
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2014-03-13 12:11:01 +0000
committerSimon Peyton Jones <simonpj@microsoft.com>2014-03-13 12:11:01 +0000
commit518706bf6ec91ece77f2195cbb1361ebbc1972f0 (patch)
tree6589487c0c45e2e4f2136e91a5536af6775ff924 /libraries/base/Data/Bits.hs
parent0d66095d5080f190d18d6d5f8b85ac7138236cb0 (diff)
downloadhaskell-518706bf6ec91ece77f2195cbb1361ebbc1972f0.tar.gz
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
Diffstat (limited to 'libraries/base/Data/Bits.hs')
-rw-r--r--libraries/base/Data/Bits.hs3
1 files changed, 3 insertions, 0 deletions
diff --git a/libraries/base/Data/Bits.hs b/libraries/base/Data/Bits.hs
index 28cd0241db..81b180bb7e 100644
--- a/libraries/base/Data/Bits.hs
+++ b/libraries/base/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