File tree 2 files changed +8
-0
lines changed
Utils/Containers/Internal
2 files changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -150,6 +150,8 @@ mask i m = i .&. ((-m) `xor` m)
150
150
{-# INLINE mask #-}
151
151
152
152
-- | The first switching bit where the two prefixes disagree.
153
+ --
154
+ -- Precondition for defined behavior: p1 /= p2
153
155
branchMask :: Int -> Int -> Int
154
156
branchMask p1 p2 = iHighestBitMask (p1 `xor` p2)
155
157
{-# INLINE branchMask #-}
Original file line number Diff line number Diff line change @@ -44,11 +44,15 @@ import GHC.Exts (Int(..), uncheckedIShiftRL#)
44
44
#endif
45
45
46
46
-- | An @Int@ where only the highest bit is set.
47
+ --
48
+ -- Precondition for defined behavior: w /= 0
47
49
iHighestBitMask :: Int -> Int
48
50
iHighestBitMask w = unsafeShiftL 1 (wordSize - 1 - countLeadingZeros w)
49
51
{-# INLINE iHighestBitMask #-}
50
52
51
53
-- Right and left logical shifts.
54
+ --
55
+ -- Precondition for defined behavior: 0 <= shift amount < wordSize
52
56
shiftRL , shiftLL :: Word -> Int -> Word
53
57
shiftRL = unsafeShiftR
54
58
shiftLL = unsafeShiftL
@@ -58,6 +62,8 @@ wordSize :: Int
58
62
wordSize = finiteBitSize (0 :: Word )
59
63
60
64
-- Right logical shift.
65
+ --
66
+ -- Precondition for defined behavior: 0 <= shift amount < wordSize
61
67
iShiftRL :: Int -> Int -> Int
62
68
#ifdef __GLASGOW_HASKELL__
63
69
iShiftRL (I # x# ) (I # sh# ) = I # (uncheckedIShiftRL# x# sh# )
You can’t perform that action at this time.
0 commit comments