diff options
author | Noel Grandin <noel@peralex.com> | 2021-08-28 18:53:07 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-08-31 14:26:46 +0200 |
commit | bb5425ed3d8cc04e4242059a17912752d6b48c53 (patch) | |
tree | 4d6b2e92939a26a0a94499cc83a7764104fd5ce3 /include/o3tl/hash_combine.hxx | |
parent | tdf#142881 XLSX import: fix shapes rotated exactly 45°, (diff) | |
download | core-bb5425ed3d8cc04e4242059a17912752d6b48c53.tar.gz core-bb5425ed3d8cc04e4242059a17912752d6b48c53.zip |
tdf#135683 speed up writer layout cache access
can be hot, so use a std::unordered_map
Change-Id: I70e34e80cad67536414c71facbe0222dd88c65a7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121208
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'include/o3tl/hash_combine.hxx')
-rw-r--r-- | include/o3tl/hash_combine.hxx | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/include/o3tl/hash_combine.hxx b/include/o3tl/hash_combine.hxx index 139ee981699c..f56beda62672 100644 --- a/include/o3tl/hash_combine.hxx +++ b/include/o3tl/hash_combine.hxx @@ -12,6 +12,17 @@ namespace o3tl { template <typename T, typename N> +inline std::enable_if_t<(sizeof(N) == 4)> hash_combine(N& nSeed, T const* pValue, size_t nCount) +{ + static_assert(sizeof(nSeed) == 4); + for (size_t i = 0; i < nCount; ++i) + { + nSeed ^= std::hash<T>{}(*pValue) + 0x9E3779B9u + (nSeed << 6) + (nSeed >> 2); + ++pValue; + } +} + +template <typename T, typename N> inline std::enable_if_t<(sizeof(N) == 4)> hash_combine(N& nSeed, T const& nValue) { static_assert(sizeof(nSeed) == 4); @@ -19,6 +30,17 @@ inline std::enable_if_t<(sizeof(N) == 4)> hash_combine(N& nSeed, T const& nValue } template <typename T, typename N> +inline std::enable_if_t<(sizeof(N) == 8)> hash_combine(N& nSeed, T const* pValue, size_t nCount) +{ + static_assert(sizeof(nSeed) == 8); + for (size_t i = 0; i < nCount; ++i) + { + nSeed ^= std::hash<T>{}(*pValue) + 0x9E3779B97F4A7C15llu + (nSeed << 12) + (nSeed >> 4); + ++pValue; + } +} + +template <typename T, typename N> inline std::enable_if_t<(sizeof(N) == 8)> hash_combine(N& nSeed, T const& nValue) { static_assert(sizeof(nSeed) == 8); |