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
slight simplification/generalization
  • Loading branch information
stevengj committed Jun 12, 2017
commit a1b0431b1222dfe023948690c1fd98ddc9ea8aa3
2 changes: 1 addition & 1 deletion base/loading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ function compilecache(name::String)
if success(create_expr_cache(path, cachefile, concrete_deps))
# append checksum to the end of the .ji file:
open(cachefile, "a+") do f
write(f, hton(crc32c(seekstart(f), filesize(f))))
write(f, hton(crc32c(seekstart(f))))
end
else
error("Failed to precompile $name to $cachefile.")
Expand Down
7 changes: 1 addition & 6 deletions base/util.jl
Original file line number Diff line number Diff line change
Expand Up @@ -817,12 +817,7 @@ function crc32c(io::IO, nb::Integer, crc::UInt32=0x00000000)
return unsafe_crc32c(buf, readbytes!(io, buf, nb), crc)
end
crc32c(io::IO, crc::UInt32=0x00000000) = crc32c(io, typemax(Int64), crc)

# optimization for `open(crc, filename)` to use the size of the file
open(::typeof(crc32c), filename::AbstractString) =
open(filename, "r") do f
crc32c(f, filesize(f))
end
crc32c(io::IOStream, crc::UInt32=0x00000000) = crc32c(io, filesize(io)-position(io), crc)


"""
Expand Down