diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-04-07 16:25:49 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-04-08 08:52:09 +0200 |
commit | 7be675cdfad328667bfbab043d71539dfd9e6fe6 (patch) | |
tree | 94a83c67d26aaffb513863a6ab0e4f8f72b2dc4d /vbahelper/source | |
parent | 1d556ff84dce01531ee334dc1408cebe50e97d22 (diff) |
improve combining in hash functions
specifically, use boost::hash_combine to combine values in hash
functions, except for a couple of places where I use the
small-prime-number strategy popular in the Java world, to avoid
including boost in header files that are widely shared.
Change-Id: I0e184c9ec8803bf09fc6e84fe20131b203e1652a
Reviewed-on: https://gerrit.libreoffice.org/70384
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'vbahelper/source')
-rw-r--r-- | vbahelper/source/vbahelper/vbaapplicationbase.cxx | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/vbahelper/source/vbahelper/vbaapplicationbase.cxx b/vbahelper/source/vbahelper/vbaapplicationbase.cxx index f65d2bfc6e35..0ea9d721157a 100644 --- a/vbahelper/source/vbahelper/vbaapplicationbase.cxx +++ b/vbahelper/source/vbahelper/vbaapplicationbase.cxx @@ -50,6 +50,7 @@ #include "vbacommandbars.hxx" +#include <boost/functional/hash.hpp> #include <unordered_map> using namespace ::com::sun::star; @@ -139,9 +140,11 @@ struct VbaTimerInfoHash { size_t operator()( const VbaTimerInfo& rTimerInfo ) const { - return static_cast<size_t>(rTimerInfo.first.hashCode()) - + static_cast<size_t>(rtl_str_hashCode_WithLength( reinterpret_cast<char const *>(&rTimerInfo.second.first), sizeof( double ) )) - + static_cast<size_t>(rtl_str_hashCode_WithLength( reinterpret_cast<char const *>(&rTimerInfo.second.second), sizeof( double ) )); + std::size_t seed = 0; + boost::hash_combine(seed, rTimerInfo.first.hashCode()); + boost::hash_combine(seed, rTimerInfo.second.first); + boost::hash_combine(seed, rTimerInfo.second.second); + return seed; } }; |