Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clean up and export crc32c function #22274

Merged
merged 14 commits into from
Jun 13, 2017
Prev Previous commit
Next Next commit
use crc32c block size of 8192*3, matching the underling C library
  • Loading branch information
stevengj committed Jun 9, 2017
commit 1126d0ffa6c285a33ce04d8439246c1ba21dce38
6 changes: 4 additions & 2 deletions base/util.jl
Original file line number Diff line number Diff line change
Expand Up @@ -804,8 +804,10 @@ mixed with a starting `crc` integer. If `nb` is not supplied, then
"""
function crc32c(io::IO, nb::Integer, crc::UInt32=0x00000000)
nb < 0 && throw(ArgumentError("number of bytes to checksum must be ≥ 0"))
buf = Array{UInt8}(min(nb, 16384))
while !eof(io) && nb > 16384
# use block size 24576=8192*3, since that is the threshold for
# 3-way parallel SIMD code in the underlying jl_crc32c C function.
buf = Array{UInt8}(min(nb, 24576))
while !eof(io) && nb > 24576
n = readbytes!(io, buf)
crc = unsafe_crc32c(buf, n, crc)
nb -= n
Expand Down