Skip to content

Commit

Permalink
[Bugfix] bug in 32-bit peek (#57)
Browse files Browse the repository at this point in the history
* update with bug fix

* ci support for more builds

* update with outputs
  • Loading branch information
emilypi authored Dec 8, 2023
1 parent 7080ac0 commit 5e38ef1
Show file tree
Hide file tree
Showing 6 changed files with 1,178 additions and 11 deletions.
6 changes: 3 additions & 3 deletions base64.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ library

build-depends:
base >=4.14 && <4.20
, bytestring >=0.11
, bytestring >=0.11 && <0.13
, deepseq >=1.4.4.0 && <1.6
, text >=2.0
, text >=2.0 && <2.3
, text-short ^>=0.1

hs-source-dirs: src
Expand Down Expand Up @@ -93,7 +93,7 @@ benchmark bench
base >=4.14 && <4.20
, base64
, base64-bytestring
, bytestring >=0.12
, bytestring >=0.11
, criterion
, deepseq
, random-bytestring
Expand Down
18 changes: 12 additions & 6 deletions benchmarks/Base64Bench.hs
Original file line number Diff line number Diff line change
Expand Up @@ -56,27 +56,33 @@ main =
bgroup "decode"
[ bgroup "25"
[ bench "base64-bytestring" $ whnf Bos.decode (B64.extractBase64 bs25)
, bench "base64" $ whnf B64.decodeBase64 bs25
, bench "base64-typed" $ whnf B64.decodeBase64 bs25
, bench "base64-untyped" $ whnf B64.decodeBase64Untyped (B64.extractBase64 bs25)
]
, bgroup "100"
[ bench "base64-bytestring" $ whnf Bos.decode (B64.extractBase64 bs100)
, bench "base64" $ whnf B64.decodeBase64 bs100
, bench "base64-typed" $ whnf B64.decodeBase64 bs100
, bench "base64-untyped" $ whnf B64.decodeBase64Untyped (B64.extractBase64 bs100)
]
, bgroup "1k"
[ bench "base64-bytestring" $ whnf Bos.decode (B64.extractBase64 bs1k)
, bench "base64" $ whnf B64.decodeBase64 bs1k
, bench "base64-typed" $ whnf B64.decodeBase64 bs1k
, bench "base64-untyped" $ whnf B64.decodeBase64Untyped (B64.extractBase64 bs1k)
]
, bgroup "10k"
[ bench "base64-bytestring" $ whnf Bos.decode (B64.extractBase64 bs10k)
, bench "base64" $ whnf B64.decodeBase64 bs10k
, bench "base64-typed" $ whnf B64.decodeBase64 bs10k
, bench "base64-untyped" $ whnf B64.decodeBase64Untyped (B64.extractBase64 bs10k)
]
, bgroup "100k"
[ bench "base64-bytestring" $ whnf Bos.decode (B64.extractBase64 bs100k)
, bench "base64" $ whnf B64.decodeBase64 bs100k
, bench "base64-typed" $ whnf B64.decodeBase64 bs100k
, bench "base64-untyped" $ whnf B64.decodeBase64Untyped (B64.extractBase64 bs100k)
]
, bgroup "1mm"
[ bench "base64-bytestring" $ whnf Bos.decode (B64.extractBase64 bs1mm)
, bench "base64" $ whnf B64.decodeBase64 bs1mm
, bench "base64-typed" $ whnf B64.decodeBase64 bs1mm
, bench "base64-untyped" $ whnf B64.decodeBase64Untyped (B64.extractBase64 bs1mm)
]
]
]
Expand Down
2 changes: 2 additions & 0 deletions cabal.project.local
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ignore-project: False
optimization: False
1,159 changes: 1,159 additions & 0 deletions output.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/Data/ByteString/Base64/Internal/W64/Loop.hs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ innerLoop
innerLoop !etable !sptr !dptr !end finish = go sptr dptr
where
go !src !dst
| plusPtr src 5 >= end =
| plusPtr src 7 >= end =
W16.innerLoop etable (castPtr src) (castPtr dst) (castPtr end) finish
| otherwise = do
!t <- peekWord64BE src
Expand Down
2 changes: 1 addition & 1 deletion test/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ offsetVectors Harness{..} = testGroup "Offset tests"
decodeUrl "PD%=" @=? Left "invalid base64 encoding near offset: 2"
decodeUrl "PA=%" @=? Left "invalid base64 encoding near offset: 3"
decodeUrl "PDw%" @=? Left "invalid base64 encoding near offset: 3"
, testCase "Invalid base64 encoding near coverage - decode chunk" $ do
, testCase "Invalid character coverage - decode chunk" $ do
decodeUrl "%Dw_PDw_" @=? Left "invalid base64 encoding near offset: 0"
decodeUrl "P%w_PDw_" @=? Left "invalid base64 encoding near offset: 1"
decodeUrl "PD%_PDw_" @=? Left "invalid base64 encoding near offset: 2"
Expand Down

0 comments on commit 5e38ef1

Please sign in to comment.