Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use CRC32c hashing directly instead of StableHashTraits (#3667)
* use CRC32c hashing directly instead of StableHashTraits * remove Point2d import * add changelog
- Loading branch information
1 parent
86a66eb
commit 9cf688d
Showing
6 changed files
with
31 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using CRC32c | ||
|
||
# Seems like crc32c is slow enough, that it's worthwhile to memoize the hashes | ||
const MEMOIZED_HASHES = Dict{Any,UInt32}() | ||
|
||
function fast_stable_hash(x) | ||
return get!(MEMOIZED_HASHES, x) do | ||
return hash_crc32(x) | ||
end | ||
end | ||
|
||
# Anything writeable to IO can be hashed | ||
function hash_crc32(arrays::Union{AbstractVector,Tuple}) | ||
io = IOBuffer() | ||
for array in arrays | ||
write(io, array) | ||
end | ||
seekstart(io) | ||
return CRC32c.crc32c(io) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters