diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2024-01-06 15:43:19 +0600 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2024-01-07 14:50:10 +0100 |
commit | 4eeb6178fb9fb499bc417a42f8d6d0bdde9acb8e (patch) | |
tree | cc5b73ba13ab8ab1a2939c02afcf20ed70981893 /include/rtl/ustring.hxx | |
parent | a46db49e301e71d78b356c57adfae6e79d3c38b5 (diff) |
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.kaganski@collabora.com>
Diffstat (limited to 'include/rtl/ustring.hxx')
-rw-r--r-- | include/rtl/ustring.hxx | 4 |
1 files changed, 2 insertions, 2 deletions
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 |