Skip to content

Commit

Permalink
Remove redundant (.&. 127) from putVarInt (#396)
Browse files Browse the repository at this point in the history
Some evidence of that redundancy:
```
> quickCheck (\(x :: Word64) -> (fromIntegral (x .|. 128) :: Word8) == (fromIntegral (x .&. 127 .|. 128) :: Word8))
+++ OK, passed 100 tests.
```

Co-authored-by: Dmitry Ivanov <ethercrow@gmail.com>
  • Loading branch information
judah and ethercrow authored Aug 15, 2020
1 parent 0ac7a36 commit f1402da
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion proto-lens/src/Data/ProtoLens/Encoding/Bytes.hs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ testMsb b = (b .&. 128) /= 0
putVarInt :: Word64 -> Builder
putVarInt n
| n < 128 = Builder.word8 (fromIntegral n)
| otherwise = Builder.word8 (fromIntegral $ n .&. 127 .|. 128)
| otherwise = Builder.word8 (fromIntegral $ n .|. 128)
<> putVarInt (n `shiftR` 7)

getFixed32 :: Parser Word32
Expand Down

0 comments on commit f1402da

Please sign in to comment.