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

[CRC32c] Support AbstractVector{UInt8} as input #56164

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

nhz2
Copy link
Contributor

@nhz2 nhz2 commented Oct 14, 2024

This is a similar PR to JuliaIO/CRC32.jl#12

I added a generic fallback method for AbstractVector{UInt8} similar to the existing generic IO method.

@@ -51,6 +51,5 @@ mixed with a starting `crc` integer. If `nb` is not supplied, then
"""
crc32c(io::IO, nb::Integer, crc::UInt32=0x00000000) = Base._crc32c(io, nb, crc)
crc32c(io::IO, crc::UInt32=0x00000000) = Base._crc32c(io, crc)
crc32c(io::IOStream, crc::UInt32=0x00000000) = Base._crc32c(io, crc)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method is redundant with the method above.

@@ -30,13 +29,14 @@ calling [`take!`](@ref).

For a `String`, note that the result is specific to the UTF-8 encoding
(a different checksum would be obtained from a different Unicode encoding).
To checksum an `a::Array` of some other bitstype, you can do `crc32c(reinterpret(UInt8,a))`,
Copy link
Contributor Author

@nhz2 nhz2 Oct 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't work if a has padding or is multidimensional. I updated the docstring to note that a must not have padding, and that vec should be used in addition to reinterpret(UInt8.

@nhz2 nhz2 marked this pull request as ready for review October 14, 2024 15:59
@nhz2 nhz2 added the feature Indicates new feature / enhancement requests label Oct 14, 2024
@nhz2 nhz2 requested a review from stevengj October 14, 2024 16:01
base/util.jl Outdated Show resolved Hide resolved
base/util.jl Outdated Show resolved Hide resolved
@nhz2 nhz2 marked this pull request as draft October 15, 2024 16:19
@nhz2 nhz2 marked this pull request as ready for review October 15, 2024 19:22
@nhz2 nhz2 requested a review from stevengj October 15, 2024 19:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Indicates new feature / enhancement requests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants