diff --git a/NEWS.md b/NEWS.md index e20f62d146e48..d6ecbf2762e14 100644 --- a/NEWS.md +++ b/NEWS.md @@ -17,7 +17,9 @@ Language changes * `mod(x::AbstractFloat, -Inf)` now returns `x` (as long as `x` is finite), this aligns with C standard and is considered a bug fix ([#47102]) - - The `hash` algorithm and its values have changed. Most `hash` specializations will remain correct and require no action. Types that reimplement the core hashing logic independently, such as some third-party string packages do, may require a migration to the new algorithm. ([#57509]) +* The `hash` algorithm and its values have changed for certain types, most notably AbstractString. Any `hash` specializations for equal types to those that changed, such as some third-party string packages, may need to be deleted. ([#57509], [#59691]) + +* The `hash(::AbstractString)` function is now a zero-copy / zero-cost function, based upon providing a correct implementation of the `codeunit` and `iterate` functions. Third-party string packages should migrate to the new algorithm by deleting their existing overrides of the `hash` function. ([#59691]) * Indexless `getindex` and `setindex!` (i.e. `A[]`) on `ReinterpretArray` now correctly throw a `BoundsError` when there is more than one element. ([#58814]) diff --git a/base/hashing.jl b/base/hashing.jl index 56c8c5c3b9e0f..2556c9265dbb4 100644 --- a/base/hashing.jl +++ b/base/hashing.jl @@ -629,7 +629,3 @@ hash(data::AbstractString, h::UInt) = hash_bytes(utf8units(data), UInt64(h), HASH_SECRET) % UInt @assume_effects :total hash(data::String, h::UInt) = GC.@preserve data hash_bytes(pointer(data), sizeof(data), UInt64(h), HASH_SECRET) % UInt - -# no longer used in Base, but a lot of packages access these internals -const memhash = UInt === UInt64 ? :memhash_seed : :memhash32_seed -const memhash_seed = UInt === UInt64 ? 0x71e729fd56419c81 : 0x56419c81