Skip to content

Commit

Permalink
Clarify types used for memoized fast_stable_hash (#3815)
Browse files Browse the repository at this point in the history
* clarify types for fast_stable_hash

* revert order
  • Loading branch information
SimonDanisch authored Apr 29, 2024
1 parent d02c233 commit 2a2a271
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/utilities/stable-hashing.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using CRC32c

# Seems like crc32c is slow enough, that it's worthwhile to memoize the hashes
const MEMOIZED_HASHES = Dict{Any,UInt32}()
const MEMOIZED_HASHES = Dict{Tuple{UInt64,String},UInt32}()

function fast_stable_hash(x)
function fast_stable_hash(x::Tuple{UInt64,String})
return get!(MEMOIZED_HASHES, x) do
return hash_crc32(x)
end
Expand Down
1 change: 1 addition & 0 deletions src/utilities/texture_atlas.jl
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ function insert_glyph!(atlas::TextureAtlas, path::BezierPath)
return insert_glyph!(atlas, fast_stable_hash(path), path)
end


function insert_glyph!(atlas::TextureAtlas, hash::UInt32, path_or_glyp::Union{BezierPath, Tuple{UInt64, NativeFont}})
return get!(atlas.mapping, hash) do
uv_pixel = render(atlas, path_or_glyp)
Expand Down

0 comments on commit 2a2a271

Please sign in to comment.