cppuhelper/qa/ifcontainer/cppu_ifcontainer.cxx | 18 ------------- include/rtl/string.hxx | 14 ++++++++++ oox/source/export/shapes.cxx | 20 +-------------- sdext/source/minimizer/pppoptimizertoken.cxx | 16 ------------ svx/source/customshapes/EnhancedCustomShapeTypeNames.cxx | 17 +----------- vcl/generic/glyphs/gcach_ftyp.cxx | 5 +-- xmloff/source/draw/EnhancedCustomShapeToken.cxx | 16 ------------ 7 files changed, 23 insertions(+), 83 deletions(-)
New commits: commit 1857688e1f4ba982d147a9cac69fad948361d1c0 Author: Herbert Dürr <[email protected]> Date: Wed May 8 15:17:19 2013 +0000 Resolves: #i122208# introduce rtl::CStringHash and rtl::CStringEqual unify the various c-string compares and hashes. (cherry picked from commit b7e3470a154538a92f0a21b14e726d75723f4a92) Conflicts: oox/inc/oox/export/shapes.hxx oox/source/export/shapes.cxx sal/inc/rtl/string.hxx sdext/source/minimizer/pppoptimizertoken.cxx svx/source/customshapes/EnhancedCustomShapeTypeNames.cxx vcl/source/glyphs/gcach_ftyp.cxx writerfilter/source/resourcemodel/TagLogger.cxx xmloff/source/draw/EnhancedCustomShapeToken.cxx Change-Id: Ib742744077bfb4d38a462d88b44bdef45601b4ae diff --git a/cppuhelper/qa/ifcontainer/cppu_ifcontainer.cxx b/cppuhelper/qa/ifcontainer/cppu_ifcontainer.cxx index 5f6467e..3a5c8cf 100644 --- a/cppuhelper/qa/ifcontainer/cppu_ifcontainer.cxx +++ b/cppuhelper/qa/ifcontainer/cppu_ifcontainer.cxx @@ -34,22 +34,6 @@ using namespace com::sun::star; using namespace com::sun::star::uno; using namespace com::sun::star::lang; - -struct equalStr -{ - bool operator()( - const char * const &rA, - const char * const &rB) const - { return !strcmp(rA, rB); } -}; -struct hashStr -{ - size_t operator()( const char * &rName ) const - { - return rtl::OString(rName).hashCode(); - } -}; - class ContainerListener; struct ContainerStats { @@ -254,7 +238,7 @@ namespace cppu_ifcontainer void testOMultiTypeInterfaceContainerHelperVar() { typedef ::cppu::OMultiTypeInterfaceContainerHelperVar< - const char *,hashStr,equalStr> StrContainer; + const char*, rtl::CStringHash, rtl::CStringEqual> StrContainer; const char *pTypes[nTests] = { diff --git a/include/rtl/string.hxx b/include/rtl/string.hxx index e3d5afb..00baeec 100644 --- a/include/rtl/string.hxx +++ b/include/rtl/string.hxx @@ -1672,6 +1672,20 @@ struct OStringHash { return (size_t)rString.hashCode(); } }; +/** Equality functor for classic c-strings (i.e. null-terminated char* strings) */ +struct CStringEqual +{ + bool operator()( const char* p1, const char* p2) const + { return rtl_str_compare(p1, p2) == 0; } +}; + +/** Hashing functor for classic c-strings (i.e. null-terminated char* strings) */ +struct CStringHash +{ + size_t operator()(const char* p) const + { return rtl_str_hashCode(p); } +}; + /* ======================================================================= */ /** diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx index dab14ce..2f918c2 100644 --- a/oox/source/export/shapes.cxx +++ b/oox/source/export/shapes.cxx @@ -509,23 +509,7 @@ static const CustomShapeTypeTranslationTable pCustomShapeTypeTranslationTable[] { "ooxml-ribbon", "ribbon" }, }; -struct StringHash -{ - size_t operator()( const char* s ) const - { - return rtl_str_hashCode(s); - } -}; - -struct StringCheck -{ - bool operator()( const char* s1, const char* s2 ) const - { - return strcmp( s1, s2 ) == 0; - } -}; - -typedef boost::unordered_map< const char*, const char*, StringHash, StringCheck> CustomShapeTypeTranslationHashMap; +typedef boost::unordered_map< const char*, const char*, rtl::CStringHash, rtl::CStringEqual> CustomShapeTypeTranslationHashMap; static CustomShapeTypeTranslationHashMap* pCustomShapeTypeTranslationHashMap = NULL; static const char* lcl_GetPresetGeometry( const char* sShapeType ) @@ -1109,7 +1093,7 @@ ShapeExport& ShapeExport::WriteRectangleShape( Reference< XShape > xShape ) } typedef ShapeExport& (ShapeExport::*ShapeConverter)( Reference< XShape > ); -typedef boost::unordered_map< const char*, ShapeConverter, StringHash, StringCheck> NameToConvertMapType; +typedef boost::unordered_map< const char*, ShapeConverter, rtl::CStringHash, rtl::CStringEqual> NameToConvertMapType; static const NameToConvertMapType& lcl_GetConverters() { diff --git a/sdext/source/minimizer/pppoptimizertoken.cxx b/sdext/source/minimizer/pppoptimizertoken.cxx index 78ae022..f4d8b40 100644 --- a/sdext/source/minimizer/pppoptimizertoken.cxx +++ b/sdext/source/minimizer/pppoptimizertoken.cxx @@ -24,21 +24,7 @@ #include <boost/unordered_map.hpp> #include <string.h> -struct THash -{ - size_t operator()( const char* s ) const - { - return rtl_str_hashCode(s); - } -}; -struct TCheck -{ - bool operator()( const char* s1, const char* s2 ) const - { - return strcmp( s1, s2 ) == 0; - } -}; -typedef boost::unordered_map< const char*, PPPOptimizerTokenEnum, THash, TCheck> TypeNameHashMap; +typedef boost::unordered_map< const char*, PPPOptimizerTokenEnum, rtl::CStringHash, rtl::CStringEqual> TypeNameHashMap; static TypeNameHashMap* pHashMap = NULL; static ::osl::Mutex& getHashMapMutex() { diff --git a/svx/source/customshapes/EnhancedCustomShapeTypeNames.cxx b/svx/source/customshapes/EnhancedCustomShapeTypeNames.cxx index 9c06dab..ca8dfde 100644 --- a/svx/source/customshapes/EnhancedCustomShapeTypeNames.cxx +++ b/svx/source/customshapes/EnhancedCustomShapeTypeNames.cxx @@ -21,21 +21,8 @@ #include <osl/mutex.hxx> #include <boost/unordered_map.hpp> -struct THash -{ - size_t operator()( const char* s ) const - { - return rtl_str_hashCode(s); - } -}; -struct TCheck -{ - bool operator()( const char* s1, const char* s2 ) const - { - return strcmp( s1, s2 ) == 0; - } -}; -typedef boost::unordered_map< const char*, MSO_SPT, THash, TCheck> TypeNameHashMap; +typedef boost::unordered_map< const char*, MSO_SPT, rtl::CStringHash, rtl::CStringEqual> TypeNameHashMap; + static TypeNameHashMap* pHashMap = NULL; static ::osl::Mutex& getHashMapMutex() { diff --git a/vcl/generic/glyphs/gcach_ftyp.cxx b/vcl/generic/glyphs/gcach_ftyp.cxx index 75564d1..13e6aa9 100644 --- a/vcl/generic/glyphs/gcach_ftyp.cxx +++ b/vcl/generic/glyphs/gcach_ftyp.cxx @@ -135,9 +135,8 @@ void (*pFTEmbolden)(FT_GlyphSlot); static FT_UInt (*pFT_Face_GetCharVariantIndex)(FT_Face, FT_ULong, FT_ULong); static bool bEnableSizeFT = false; -struct EqStr{ bool operator()(const char* a, const char* b) const { return !strcmp(a,b); } }; -struct HashStr { size_t operator()( const char* s ) const { return rtl_str_hashCode(s); } }; -typedef ::boost::unordered_map<const char*,boost::shared_ptr<FtFontFile>,HashStr, EqStr> FontFileList; +typedef ::boost::unordered_map<const char*, boost::shared_ptr<FtFontFile>, rtl::CStringHash, rtl::CStringEqual> FontFileList; + namespace { struct vclFontFileList : public rtl::Static< FontFileList, vclFontFileList > {}; } // ----------------------------------------------------------------------- diff --git a/xmloff/source/draw/EnhancedCustomShapeToken.cxx b/xmloff/source/draw/EnhancedCustomShapeToken.cxx index 6f9c520..d9c45ea 100644 --- a/xmloff/source/draw/EnhancedCustomShapeToken.cxx +++ b/xmloff/source/draw/EnhancedCustomShapeToken.cxx @@ -24,21 +24,7 @@ namespace xmloff { namespace EnhancedCustomShapeToken { -struct THash -{ - size_t operator()( const char* s ) const - { - return rtl_str_hashCode(s); - } -}; -struct TCheck -{ - bool operator()( const char* s1, const char* s2 ) const - { - return strcmp( s1, s2 ) == 0; - } -}; -typedef boost::unordered_map< const char*, EnhancedCustomShapeTokenEnum, THash, TCheck> TypeNameHashMap; +typedef boost::unordered_map< const char*, EnhancedCustomShapeTokenEnum, rtl::CStringHash, rtl::CStringEqual> TypeNameHashMap; static TypeNameHashMap* pHashMap = NULL; static ::osl::Mutex& getHashMapMutex() {
_______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
