Skip to content

Commit

Permalink
fix slow hash(::SubString{<:ByteString})
Browse files Browse the repository at this point in the history
Cuts the JuliaLang#8826 vocab.jl benchmark in half.
  • Loading branch information
nolta committed Nov 6, 2014
1 parent cd450f6 commit 4b4565f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion base/string.jl
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ const memhash_seed = UInt === UInt64 ? 0x71e729fd56419c81 : 0x56419c81

function hash{T<:ByteString}(s::Union(T,SubString{T}), h::UInt)
h += memhash_seed
ccall(memhash, UInt, (Ptr{UInt8}, Csize_t, UInt32), s, sizeof(s), h % UInt32) + h
ccall(memhash, UInt, (Ptr{UInt8}, Csize_t, UInt32), pointer(s), sizeof(s), h % UInt32) + h
end
hash(s::AbstractString, h::UInt) = hash(bytestring(s), h)

Expand Down

0 comments on commit 4b4565f

Please sign in to comment.