include/rtl/string.hxx | 4 ++-- include/rtl/ustring.hxx | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
New commits: commit bc7ea997d5f6bb5a185fed76927175a53b87f7fc Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Sat Jan 6 15:43:19 2024 +0600 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Tue Jan 9 15:09:50 2024 +0100 tdf#159018: make 64-bit hash algorithm similar to 32-bit one The magic of choosing a substitution font depends on the order of fontfaces returned from PhysicalFontCollection::GetFontFaceCollection (called from WinGlyphFallbackSubstititution::FindFontSubstitute). Since commit db04b3e154a1fb8f222232ef969bb3617e051329 (return 64-bit hash for O[U]String, 2022-08-22), the order has changed, which resulted in different fallbacks in some documents (which aren't well-formed in respect to their formatting, so when they work, it's just luck). The difference was because the 64-bit hash implementation was modelled after Java one. This patch makes the code follow the algorithm in rtl::str::hashCode_WithLength, used in 32-bit hash, which restores the order (at least for my system). Not reliable, just "why not". Change-Id: I3c482e86bee79d6c9c6981300518c4ff6b7f29d5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161706 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> (cherry picked from commit 4eeb6178fb9fb499bc417a42f8d6d0bdde9acb8e) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161753 Reviewed-by: Michael Stahl <michael.st...@allotropia.de> diff --git a/include/rtl/string.hxx b/include/rtl/string.hxx index ce683beb5e60..91fb155a5e9d 100644 --- a/include/rtl/string.hxx +++ b/include/rtl/string.hxx @@ -2431,9 +2431,9 @@ struct hash<::rtl::OString> if constexpr (sizeof(std::size_t) == 8) { // return a hash that uses the full 64-bit range instead of a 32-bit value - size_t n = 0; + size_t n = s.getLength(); for (sal_Int32 i = 0, len = s.getLength(); i < len; ++i) - n = 31 * n + s[i]; + n = 37 * n + s[i]; return n; } else diff --git a/include/rtl/ustring.hxx b/include/rtl/ustring.hxx index cad8cc10ac48..c32a083f10b5 100644 --- a/include/rtl/ustring.hxx +++ b/include/rtl/ustring.hxx @@ -3593,9 +3593,9 @@ struct hash<::rtl::OUString> if constexpr (sizeof(std::size_t) == 8) { // return a hash that uses the full 64-bit range instead of a 32-bit value - size_t n = 0; + size_t n = s.getLength(); for (sal_Int32 i = 0, len = s.getLength(); i < len; ++i) - n = 31 * n + s[i]; + n = 37 * n + s[i]; return n; } else