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 | |
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>
-rw-r--r-- | basctl/source/basicide/bastypes.cxx | 6 | ||||
-rw-r--r-- | filter/inc/gfxtypes.hxx | 97 | ||||
-rw-r--r-- | include/svx/sdasitm.hxx | 5 | ||||
-rw-r--r-- | include/xmloff/nmspmap.hxx | 5 | ||||
-rw-r--r-- | sc/inc/externalrefmgr.hxx | 9 | ||||
-rw-r--r-- | sc/source/core/data/dpresfilter.cxx | 7 | ||||
-rw-r--r-- | sc/source/ui/view/spellcheckcontext.cxx | 9 | ||||
-rw-r--r-- | sdext/source/pdfimport/inc/pdfihelper.hxx | 66 | ||||
-rw-r--r-- | vbahelper/source/vbahelper/vbaapplicationbase.cxx | 9 | ||||
-rw-r--r-- | vcl/source/font/fontinstance.cxx | 7 | ||||
-rw-r--r-- | vcl/unx/generic/glyphs/glyphcache.cxx | 18 | ||||
-rw-r--r-- | vcl/unx/generic/printer/ppdparser.cxx | 12 | ||||
-rw-r--r-- | xmloff/inc/StyleMap.hxx | 7 | ||||
-rw-r--r-- | xmloff/source/core/xmltkmap.cxx | 6 | ||||
-rw-r--r-- | xmloff/source/forms/property_meta_data.cxx | 6 | ||||
-rw-r--r-- | xmloff/source/transform/TransformerActions.hxx | 7 |
16 files changed, 161 insertions, 115 deletions
diff --git a/basctl/source/basicide/bastypes.cxx b/basctl/source/basicide/bastypes.cxx index 6fe3475c49e8..ffb3e9d87f83 100644 --- a/basctl/source/basicide/bastypes.cxx +++ b/basctl/source/basicide/bastypes.cxx @@ -36,6 +36,7 @@ #include <svl/srchdefs.hxx> #include <vcl/weld.hxx> #include <tools/stream.hxx> +#include <boost/functional/hash.hpp> namespace basctl { @@ -693,7 +694,10 @@ bool LibInfo::Key::operator == (Key const& rKey) const size_t LibInfo::Key::Hash::operator () (Key const& rKey) const { - return rKey.m_aDocument.hashCode() + rKey.m_aLibName.hashCode(); + std::size_t seed = 0; + boost::hash_combine(seed, rKey.m_aDocument.hashCode()); + boost::hash_combine(seed, rKey.m_aLibName.hashCode()); + return seed; } LibInfo::Item::Item ( diff --git a/filter/inc/gfxtypes.hxx b/filter/inc/gfxtypes.hxx index 365e381c0ab4..af180e2e1d3a 100644 --- a/filter/inc/gfxtypes.hxx +++ b/filter/inc/gfxtypes.hxx @@ -16,6 +16,7 @@ #include <functional> #include <unordered_set> #include <unordered_map> +#include <boost/functional/hash.hpp> namespace svgi { @@ -264,53 +265,55 @@ namespace std using argument_type = svgi::State; std::size_t operator()(const svgi::State& rState ) const { - return std::hash<double>()(rState.maCTM.get( 0, 0 )) - ^ std::hash<double>()(rState.maCTM.get( 1, 0 )) - ^ std::hash<double>()(rState.maCTM.get( 0, 1 )) - ^ std::hash<double>()(rState.maCTM.get( 1, 1 )) - ^ std::hash<double>()(rState.maCTM.get( 0, 2 )) - ^ std::hash<double>()(rState.maCTM.get( 1, 2 )) - ^ std::hash<double>()(rState.maViewport.getWidth()) - ^ std::hash<double>()(rState.maViewport.getHeight()) - ^ std::hash<double>()(rState.maViewBox.getWidth()) - ^ std::hash<double>()(rState.maViewBox.getHeight()) - ^ size_t(rState.mbIsText) - ^ size_t(rState.maFontFamily.hashCode()) - ^ std::hash<double>()(rState.mnFontSize) - ^ std::hash<double>()(rState.mnParentFontSize) - ^ size_t(rState.maFontStyle.hashCode()) - ^ size_t(rState.maFontVariant.hashCode()) - ^ std::hash<double>()(rState.mnFontWeight) - ^ size_t(rState.meTextAnchor) - ^ size_t(rState.mbVisibility) - ^ size_t(rState.meFillType) - ^ std::hash<double>()(rState.mnFillOpacity) - ^ std::hash<double>()(rState.mnOpacity) - ^ size_t(rState.meStrokeType) - ^ std::hash<double>()(rState.mnStrokeOpacity) - ^ std::hash<double>()(rState.mnViewportFillOpacity) - ^ size_t(rState.maFillColor.a) - ^ size_t(rState.maFillColor.r) - ^ size_t(rState.maFillColor.g) - ^ size_t(rState.maFillColor.b) - ^ size_t(rState.maFillGradient.maStops.size()) - ^ size_t(rState.meFillRule) - ^ size_t(rState.maStrokeColor.a) - ^ size_t(rState.maStrokeColor.r) - ^ size_t(rState.maStrokeColor.g) - ^ size_t(rState.maStrokeColor.b) - ^ size_t(rState.maStrokeGradient.maStops.size()) - ^ size_t(rState.maDashArray.size()) - ^ std::hash<double>()(rState.mnDashOffset) - ^ size_t(rState.meLineCap) - ^ size_t(rState.meLineJoin) - ^ std::hash<double>()(rState.mnMiterLimit) - ^ std::hash<double>()(rState.mnStrokeWidth) - ^ size_t(rState.maViewportFillColor.a) - ^ size_t(rState.maViewportFillColor.r) - ^ size_t(rState.maViewportFillColor.g) - ^ size_t(rState.maViewportFillColor.b) - ^ size_t(rState.maViewportFillGradient.maStops.size()); + std::size_t seed = 0; + boost::hash_combine(seed, rState.maCTM.get( 0, 0 )); + boost::hash_combine(seed, rState.maCTM.get( 1, 0 )); + boost::hash_combine(seed, rState.maCTM.get( 0, 1 )); + boost::hash_combine(seed, rState.maCTM.get( 1, 1 )); + boost::hash_combine(seed, rState.maCTM.get( 0, 2 )); + boost::hash_combine(seed, rState.maCTM.get( 1, 2 )); + boost::hash_combine(seed, rState.maViewport.getWidth()); + boost::hash_combine(seed, rState.maViewport.getHeight()); + boost::hash_combine(seed, rState.maViewBox.getWidth()); + boost::hash_combine(seed, rState.maViewBox.getHeight()); + boost::hash_combine(seed, rState.mbIsText); + boost::hash_combine(seed, rState.maFontFamily); + boost::hash_combine(seed, rState.mnFontSize); + boost::hash_combine(seed, rState.mnParentFontSize); + boost::hash_combine(seed, rState.maFontStyle); + boost::hash_combine(seed, rState.maFontVariant); + boost::hash_combine(seed, rState.mnFontWeight); + boost::hash_combine(seed, rState.meTextAnchor); + boost::hash_combine(seed, rState.mbVisibility); + boost::hash_combine(seed, rState.meFillType) + boost::hash_combine(seed, rState.mnFillOpacity); + boost::hash_combine(seed, rState.mnOpacity); + boost::hash_combine(seed, rState.meStrokeType); + boost::hash_combine(seed, rState.mnStrokeOpacity); + boost::hash_combine(seed, rState.mnViewportFillOpacity); + boost::hash_combine(seed, rState.maFillColor.a); + boost::hash_combine(seed, rState.maFillColor.r); + boost::hash_combine(seed, rState.maFillColor.g); + boost::hash_combine(seed, rState.maFillColor.b); + boost::hash_combine(seed, rState.maFillGradient.maStops.size()); + boost::hash_combine(seed, rState.meFillRule); + boost::hash_combine(seed, rState.maStrokeColor.a); + boost::hash_combine(seed, rState.maStrokeColor.r); + boost::hash_combine(seed, rState.maStrokeColor.g); + boost::hash_combine(seed, rState.maStrokeColor.b); + boost::hash_combine(seed, rState.maStrokeGradient.maStops.size()); + boost::hash_combine(seed, rState.maDashArray.size()); + boost::hash_combine(seed, rState.mnDashOffset); + boost::hash_combine(seed, rState.meLineCap); + boost::hash_combine(seed, rState.meLineJoin); + boost::hash_combine(seed, rState.mnMiterLimit); + boost::hash_combine(seed, rState.mnStrokeWidth); + boost::hash_combine(seed, rState.maViewportFillColor.a); + boost::hash_combine(seed, rState.maViewportFillColor.r); + boost::hash_combine(seed, rState.maViewportFillColor.g); + boost::hash_combine(seed, rState.maViewportFillColor.b); + boost::hash_combine(seed, rState.maViewportFillGradient.maStops.size()); + return seed; } }; } diff --git a/include/svx/sdasitm.hxx b/include/svx/sdasitm.hxx index 44bdfbc714d6..3e2623b0ca76 100644 --- a/include/svx/sdasitm.hxx +++ b/include/svx/sdasitm.hxx @@ -89,7 +89,10 @@ inline SdrOnOffItem makeSdrTextWordWrapItem( bool bAuto ) { inline size_t SdrCustomShapeGeometryItem::PropertyPairHash::operator()( const SdrCustomShapeGeometryItem::PropertyPair &r1 ) const { - return static_cast<size_t>(r1.first.hashCode()) + r1.second.hashCode(); + size_t hash = 17; + hash = hash * 37 + r1.first.hashCode(); + hash = hash * 37 + r1.second.hashCode(); + return hash; }; #endif diff --git a/include/xmloff/nmspmap.hxx b/include/xmloff/nmspmap.hxx index 127d5b59f06b..1eb0f8f15b95 100644 --- a/include/xmloff/nmspmap.hxx +++ b/include/xmloff/nmspmap.hxx @@ -56,7 +56,10 @@ struct QNamePairHash { size_t operator()( const QNamePair &r1 ) const { - return static_cast<size_t>(r1.second.hashCode()) + r1.first; + size_t hash = 17; + hash = hash * 37 + r1.first; + hash = hash * 37 + r1.second.hashCode(); + return hash; } }; diff --git a/sc/inc/externalrefmgr.hxx b/sc/inc/externalrefmgr.hxx index d55693b8af46..087e05570a5d 100644 --- a/sc/inc/externalrefmgr.hxx +++ b/sc/inc/externalrefmgr.hxx @@ -305,7 +305,14 @@ private: { const ScAddress& s = rRange.aStart; const ScAddress& e = rRange.aEnd; - return s.Tab() + s.Col() + s.Row() + e.Tab() + e.Col() + e.Row(); + size_t hash = 17; + hash = hash * 37 + s.Tab(); + hash = hash * 37 + s.Col(); + hash = hash * 37 + s.Row(); + hash = hash * 37 + e.Tab(); + hash = hash * 37 + e.Col(); + hash = hash * 37 + e.Row(); + return hash; } }; diff --git a/sc/source/core/data/dpresfilter.cxx b/sc/source/core/data/dpresfilter.cxx index c4102824fe1f..2efb4563f8ee 100644 --- a/sc/source/core/data/dpresfilter.cxx +++ b/sc/source/core/data/dpresfilter.cxx @@ -13,6 +13,7 @@ #include <unotools/charclass.hxx> #include <rtl/math.hxx> #include <sal/log.hxx> +#include <boost/functional/hash.hpp> #include <com/sun/star/sheet/DataPilotFieldFilter.hpp> #include <com/sun/star/uno/Sequence.hxx> @@ -28,8 +29,10 @@ ScDPResultFilterContext::ScDPResultFilterContext() : size_t ScDPResultTree::NamePairHash::operator() (const NamePairType& rPair) const { - OUStringHash aHash; - return aHash(rPair.first) + aHash(rPair.second); + std::size_t seed = 0; + boost::hash_combine(seed, rPair.first.hashCode()); + boost::hash_combine(seed, rPair.second.hashCode()); + return seed; } ScDPResultTree::DimensionNode::DimensionNode() {} diff --git a/sc/source/ui/view/spellcheckcontext.cxx b/sc/source/ui/view/spellcheckcontext.cxx index 5f03da7d882c..867dc26f5738 100644 --- a/sc/source/ui/view/spellcheckcontext.cxx +++ b/sc/source/ui/view/spellcheckcontext.cxx @@ -8,15 +8,16 @@ */ #include <spellcheckcontext.hxx> +#include <boost/functional/hash.hpp> namespace sc { size_t SpellCheckContext::CellPos::Hash::operator() (const CellPos& rPos) const { - size_t nVal = rPos.mnCol; - nVal = nVal << 4; - nVal += rPos.mnRow; - return nVal; + std::size_t seed = 0; + boost::hash_combine(seed, rPos.mnCol); + boost::hash_combine(seed, rPos.mnRow); + return seed; } SpellCheckContext::CellPos::CellPos() : mnCol(0), mnRow(0) {} diff --git a/sdext/source/pdfimport/inc/pdfihelper.hxx b/sdext/source/pdfimport/inc/pdfihelper.hxx index 072a5bd01d50..4a7fd569688e 100644 --- a/sdext/source/pdfimport/inc/pdfihelper.hxx +++ b/sdext/source/pdfimport/inc/pdfihelper.hxx @@ -82,13 +82,14 @@ namespace pdfi { size_t operator()(const FontAttributes& rFont ) const { - return static_cast<size_t>(rFont.familyName.hashCode()) - ^ size_t(rFont.isBold ? 0xd47be593 : 0) - ^ size_t(rFont.isItalic ? 0x1efd51a1 : 0) - ^ size_t(rFont.isUnderline ? 0xf6bd325a : 0) - ^ size_t(rFont.isOutline ? 0x12345678 : 0) - ^ size_t(rFont.size) - ; + std::size_t seed = 0; + boost::hash_combine(seed, rFont.familyName.hashCode()); + boost::hash_combine(seed, rFont.isBold); + boost::hash_combine(seed, rFont.isItalic); + boost::hash_combine(seed, rFont.isUnderline); + boost::hash_combine(seed, rFont.isOutline); + boost::hash_combine(seed, rFont.size); + return seed; } }; @@ -184,31 +185,32 @@ namespace pdfi { size_t operator()(const GraphicsContext& rGC ) const { - return boost::hash_value(rGC.LineColor.Red) - ^ boost::hash_value(rGC.LineColor.Green) - ^ boost::hash_value(rGC.LineColor.Blue) - ^ boost::hash_value(rGC.LineColor.Alpha) - ^ boost::hash_value(rGC.FillColor.Red) - ^ boost::hash_value(rGC.FillColor.Green) - ^ boost::hash_value(rGC.FillColor.Blue) - ^ boost::hash_value(rGC.FillColor.Alpha) - ^ boost::hash_value(rGC.LineJoin) - ^ boost::hash_value(rGC.LineCap) - ^ boost::hash_value(rGC.BlendMode) - ^ boost::hash_value(rGC.LineWidth) - ^ boost::hash_value(rGC.Flatness) - ^ boost::hash_value(rGC.MiterLimit) - ^ rGC.DashArray.size() - ^ boost::hash_value(rGC.FontId) - ^ boost::hash_value(rGC.TextRenderMode) - ^ boost::hash_value(rGC.Transformation.get( 0, 0 )) - ^ boost::hash_value(rGC.Transformation.get( 1, 0 )) - ^ boost::hash_value(rGC.Transformation.get( 0, 1 )) - ^ boost::hash_value(rGC.Transformation.get( 1, 1 )) - ^ boost::hash_value(rGC.Transformation.get( 0, 2 )) - ^ boost::hash_value(rGC.Transformation.get( 1, 2 )) - ^ boost::hash_value(rGC.Clip.count() ? rGC.Clip.getB2DPolygon(0).count() : 0) - ; + std::size_t seed = 0; + boost::hash_combine(seed, rGC.LineColor.Red); + boost::hash_combine(seed, rGC.LineColor.Green); + boost::hash_combine(seed, rGC.LineColor.Blue); + boost::hash_combine(seed, rGC.LineColor.Alpha); + boost::hash_combine(seed, rGC.FillColor.Red); + boost::hash_combine(seed, rGC.FillColor.Green); + boost::hash_combine(seed, rGC.FillColor.Blue); + boost::hash_combine(seed, rGC.FillColor.Alpha); + boost::hash_combine(seed, rGC.LineJoin); + boost::hash_combine(seed, rGC.LineCap); + boost::hash_combine(seed, rGC.BlendMode); + boost::hash_combine(seed, rGC.LineWidth); + boost::hash_combine(seed, rGC.Flatness); + boost::hash_combine(seed, rGC.MiterLimit); + boost::hash_combine(seed, rGC.DashArray.size()); + boost::hash_combine(seed, rGC.FontId); + boost::hash_combine(seed, rGC.TextRenderMode); + boost::hash_combine(seed, rGC.Transformation.get( 0, 0 )); + boost::hash_combine(seed, rGC.Transformation.get( 1, 0 )); + boost::hash_combine(seed, rGC.Transformation.get( 0, 1 )); + boost::hash_combine(seed, rGC.Transformation.get( 1, 1 )); + boost::hash_combine(seed, rGC.Transformation.get( 0, 2 )); + boost::hash_combine(seed, rGC.Transformation.get( 1, 2 )); + boost::hash_combine(seed, rGC.Clip.count() ? rGC.Clip.getB2DPolygon(0).count() : 0); + return seed; } }; 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; } }; diff --git a/vcl/source/font/fontinstance.cxx b/vcl/source/font/fontinstance.cxx index 595259731db1..bcbbe6d94d9d 100644 --- a/vcl/source/font/fontinstance.cxx +++ b/vcl/source/font/fontinstance.cxx @@ -32,9 +32,10 @@ namespace std { size_t operator()(const pair< sal_UCS4, FontWeight >& rData) const { - size_t h1 = hash<sal_UCS4>()(rData.first); - size_t h2 = hash<int>()(rData.second); - return h1 ^ h2; + std::size_t seed = 0; + boost::hash_combine(seed, rData.first); + boost::hash_combine(seed, rData.second); + return seed; } }; } diff --git a/vcl/unx/generic/glyphs/glyphcache.cxx b/vcl/unx/generic/glyphs/glyphcache.cxx index 0aa8be45e84a..558e3d8c3323 100644 --- a/vcl/unx/generic/glyphs/glyphcache.cxx +++ b/vcl/unx/generic/glyphs/glyphcache.cxx @@ -85,15 +85,15 @@ size_t GlyphCache::IFSD_Hash::operator()(const rtl::Reference<LogicalFontInstanc nFontId ^= aFeatName.hashCode(); } - size_t nHash = nFontId << 8; - nHash += rFontSelData.mnHeight; - nHash += rFontSelData.mnOrientation; - nHash += size_t(rFontSelData.mbVertical); - nHash += rFontSelData.GetItalic(); - nHash += rFontSelData.GetWeight(); - nHash += static_cast<sal_uInt16>(rFontSelData.meLanguage); - - return nHash; + std::size_t seed = 0; + boost::hash_combine(seed, nFontId); + boost::hash_combine(seed, rFontSelData.mnHeight); + boost::hash_combine(seed, rFontSelData.mnOrientation); + boost::hash_combine(seed, size_t(rFontSelData.mbVertical)); + boost::hash_combine(seed, rFontSelData.GetItalic()); + boost::hash_combine(seed, rFontSelData.GetWeight()); + boost::hash_combine(seed, static_cast<sal_uInt16>(rFontSelData.meLanguage)); + return seed; } bool GlyphCache::IFSD_Equal::operator()(const rtl::Reference<LogicalFontInstance>& rAFontInstance, diff --git a/vcl/unx/generic/printer/ppdparser.cxx b/vcl/unx/generic/printer/ppdparser.cxx index 923d8612e7a1..aa99e3638580 100644 --- a/vcl/unx/generic/printer/ppdparser.cxx +++ b/vcl/unx/generic/printer/ppdparser.cxx @@ -54,6 +54,7 @@ #include <config_dbus.h> #include <config_gio.h> +#include <boost/functional/hash.hpp> namespace psp { @@ -73,11 +74,12 @@ namespace psp struct LocaleHash { size_t operator()(const css::lang::Locale& rLocale) const - { return - static_cast<size_t>(rLocale.Language.hashCode()) - ^ static_cast<size_t>(rLocale.Country.hashCode()) - ^ static_cast<size_t>(rLocale.Variant.hashCode()) - ; + { + std::size_t seed = 0; + boost::hash_combine(seed, rLocale.Language.hashCode()); + boost::hash_combine(seed, rLocale.Country.hashCode()); + boost::hash_combine(seed, rLocale.Variant.hashCode()); + return seed; } }; diff --git a/xmloff/inc/StyleMap.hxx b/xmloff/inc/StyleMap.hxx index 8fb76e61104d..aef67399b8cd 100644 --- a/xmloff/inc/StyleMap.hxx +++ b/xmloff/inc/StyleMap.hxx @@ -22,6 +22,7 @@ #include <com/sun/star/lang/XUnoTunnel.hpp> #include <cppuhelper/implbase.hxx> +#include <boost/functional/hash.hpp> #include <unordered_map> struct StyleNameKey_Impl @@ -46,8 +47,10 @@ struct StyleNameHash_Impl inline size_t StyleNameHash_Impl::operator()( const StyleNameKey_Impl& r ) const { - return static_cast< size_t >( r.m_nFamily ) + - static_cast< size_t >( r.m_aName.hashCode() ); + std::size_t seed = 0; + boost::hash_combine(seed, r.m_nFamily); + boost::hash_combine(seed, r.m_aName.hashCode()); + return seed; } inline bool StyleNameHash_Impl::operator()( diff --git a/xmloff/source/core/xmltkmap.cxx b/xmloff/source/core/xmltkmap.cxx index 1aca38975d9b..d89eb9621638 100644 --- a/xmloff/source/core/xmltkmap.cxx +++ b/xmloff/source/core/xmltkmap.cxx @@ -20,6 +20,7 @@ #include <rtl/ustring.hxx> #include <xmloff/xmltkmap.hxx> #include <xmloff/xmltoken.hxx> +#include <boost/functional/hash.hpp> #include <unordered_map> #include <utility> @@ -33,7 +34,10 @@ private: { std::size_t operator()(const std::pair<sal_uInt16,OUString> &pair) const { - return static_cast<std::size_t>( pair.first | pair.second.hashCode() ); + std::size_t seed = 0; + boost::hash_combine(seed, pair.first); + boost::hash_combine(seed, pair.second.hashCode()); + return seed; } }; std::unordered_map< std::pair<sal_uInt16, OUString>, diff --git a/xmloff/source/forms/property_meta_data.cxx b/xmloff/source/forms/property_meta_data.cxx index 87ccd36fc160..edf505faa45d 100644 --- a/xmloff/source/forms/property_meta_data.cxx +++ b/xmloff/source/forms/property_meta_data.cxx @@ -24,6 +24,7 @@ #include <xmloff/xmltoken.hxx> #include <xmloff/xmlnmspe.hxx> +#include <boost/functional/hash.hpp> #include <tools/debug.hxx> #include <osl/diagnose.h> #include <sal/log.hxx> @@ -128,7 +129,10 @@ namespace xmloff { namespace metadata { size_t operator()( const AttributeDescription& i_attribute ) const { - return size_t( i_attribute.attributeToken * 100 ) + size_t( i_attribute.namespacePrefix ); + std::size_t seed = 0; + boost::hash_combine(seed, i_attribute.attributeToken); + boost::hash_combine(seed, i_attribute.namespacePrefix); + return seed; } }; diff --git a/xmloff/source/transform/TransformerActions.hxx b/xmloff/source/transform/TransformerActions.hxx index 3c7f61c7c365..17109c031808 100644 --- a/xmloff/source/transform/TransformerActions.hxx +++ b/xmloff/source/transform/TransformerActions.hxx @@ -24,6 +24,7 @@ #include <xmloff/nmspmap.hxx> #include "TransformerActionInit.hxx" #include "TransformerAction.hxx" +#include <boost/functional/hash.hpp> #include <unordered_map> struct NameKey_Impl @@ -57,8 +58,10 @@ struct NameHash_Impl inline size_t NameHash_Impl::operator()( const NameKey_Impl& r ) const { - return static_cast< size_t >( r.m_nPrefix ) + - static_cast< size_t >( r.m_aLocalName.hashCode() ); + std::size_t seed = 0; + boost::hash_combine(seed, r.m_nPrefix); + boost::hash_combine(seed, r.m_aLocalName.hashCode()); + return seed; } inline bool NameHash_Impl::operator()( |