X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=Data%2FBits.hs;h=18c1f6db62c8a9ff9a7c9be877f93f91c7bc13b7;hb=0a7a4a16e555a77afec5501a75d9fbbb9fc35730;hp=638935d40eaf1b7539f63883caf4253eda1df01a;hpb=10de2c656f74562b662c22928be85e1b3ccda796;p=ghc-base.git diff --git a/Data/Bits.hs b/Data/Bits.hs index 638935d..18c1f6d 100644 --- a/Data/Bits.hs +++ b/Data/Bits.hs @@ -95,9 +95,9 @@ class Num a => Bits a where question. -} shift :: a -> Int -> a - x `shift` i | i<0 = x `shiftR` (-i) - | i==0 = x - | i>0 = x `shiftL` i + x `shift` i | i<0 = x `shiftR` (-i) + | i>0 = x `shiftL` i + | otherwise = x {-| @'rotate' x i@ rotates @x@ left by @i@ bits if @i@ is positive, or right by @-i@ bits otherwise. @@ -109,9 +109,9 @@ class Num a => Bits a where question. -} rotate :: a -> Int -> a - x `rotate` i | i<0 = x `rotateR` (-i) - | i==0 = x - | i>0 = x `rotateL` i + x `rotate` i | i<0 = x `rotateR` (-i) + | i>0 = x `rotateL` i + | otherwise = x {- -- Rotation can be implemented in terms of two shifts, but care is @@ -222,6 +222,10 @@ instance Bits Int where i'# = word2Int# (int2Word# i# `and#` int2Word# (wsib -# 1#)) wsib = WORD_SIZE_IN_BITS# {- work around preprocessor problem (??) -} bitSize _ = WORD_SIZE_IN_BITS + + {-# INLINE shiftR #-} + -- same as the default definition, but we want it inlined (#2376) + x `shiftR` i = x `shift` (-i) #else /* !__GLASGOW_HASKELL__ */ #ifdef __HUGS__