[Libreoffice-commits] core.git: include/unotools unotools/source vcl/inc vcl/source

Stephan Bergmann sbergman at redhat.com
Wed Apr 16 08:45:39 PDT 2014


 include/unotools/fontdefs.hxx      |    2 --
 unotools/source/misc/fontdefs.cxx  |   24 +-----------------------
 vcl/inc/PhysicalFontCollection.hxx |    2 +-
 vcl/source/outdev/font.cxx         |    9 ++++++---
 4 files changed, 8 insertions(+), 29 deletions(-)

New commits:
commit d67da1e7216a1b1281f418ecaa067cd3014e47c0
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Wed Apr 16 17:44:56 2014 +0200

    Remove FontNameHash, use standard OUStringHash
    
    Change-Id: If123bbe8a4ee044ef45f418be0118ccf9509f4e7

diff --git a/include/unotools/fontdefs.hxx b/include/unotools/fontdefs.hxx
index ad9a68b..6e20b88 100644
--- a/include/unotools/fontdefs.hxx
+++ b/include/unotools/fontdefs.hxx
@@ -41,8 +41,6 @@ UNOTOOLS_DLLPUBLIC OUString GetSubsFontName( const OUString& rName, sal_uLong nF
 
 UNOTOOLS_DLLPUBLIC void AddTokenFontName( OUString& rName, const OUString& rNewToken );
 
-struct UNOTOOLS_DLLPUBLIC FontNameHash { int operator()(const OUString&) const; };
-
 // - ConvertChar -
 
 class UNOTOOLS_DLLPUBLIC ConvertChar
diff --git a/unotools/source/misc/fontdefs.cxx b/unotools/source/misc/fontdefs.cxx
index 0f4206e..61f6a07 100644
--- a/unotools/source/misc/fontdefs.cxx
+++ b/unotools/source/misc/fontdefs.cxx
@@ -423,7 +423,7 @@ void GetEnglishSearchFontName( OUString& rName )
     // translate normalized localized name to its normalized English ASCII name
     if( bNeedTranslation )
     {
-        typedef boost::unordered_map<const OUString, const char*, FontNameHash> FontNameDictionary;
+        typedef boost::unordered_map<const OUString, const char*, OUStringHash> FontNameDictionary;
         static FontNameDictionary aDictionary( SAL_N_ELEMENTS(aImplLocalizedNamesList) );
         // the font name dictionary needs to be intialized once
         if( aDictionary.empty() )
@@ -568,28 +568,6 @@ OUString GetSubsFontName( const OUString& rName, sal_uLong nFlags )
     return aName;
 }
 
-// TODO: use a more generic String hash
-int FontNameHash::operator()( const OUString& rStr ) const
-{
-    // this simple hash just has to be good enough for font names
-    int nHash = 0;
-    const int nLen = rStr.getLength();
-    const sal_Unicode* p = rStr.getStr();
-    switch( nLen )
-    {
-        default: nHash = (p[0]<<16) - (p[1]<<8) + p[2];
-                 nHash += nLen;
-                 p += nLen - 3;
-                 // fall through
-        case 3:  nHash += (p[2]<<16);   // fall through
-        case 2:  nHash += (p[1]<<8);    // fall through
-        case 1:  nHash += p[0];         // fall through
-        case 0:  break;
-    };
-
-    return nHash;
-}
-
 bool IsStarSymbol(const OUString &rFontName)
 {
     sal_Int32 nIndex = 0;
diff --git a/vcl/inc/PhysicalFontCollection.hxx b/vcl/inc/PhysicalFontCollection.hxx
index 9c0c7a1..fd9eb15 100644
--- a/vcl/inc/PhysicalFontCollection.hxx
+++ b/vcl/inc/PhysicalFontCollection.hxx
@@ -35,7 +35,7 @@ private:
     mutable bool            mbMatchData;    // true if matching attributes are initialized
     bool                    mbMapNames;     // true if MapNames are available
 
-    typedef boost::unordered_map<const OUString, PhysicalFontFamily*,FontNameHash> PhysicalFontFamilies;
+    typedef boost::unordered_map<const OUString, PhysicalFontFamily*,OUStringHash> PhysicalFontFamilies;
     PhysicalFontFamilies    maPhysicalFontFamilies;
 
     ImplPreMatchFontSubstitution* mpPreMatchHook;       // device specific prematch substitution
diff --git a/vcl/source/outdev/font.cxx b/vcl/source/outdev/font.cxx
index c1565f7..c82badd 100644
--- a/vcl/source/outdev/font.cxx
+++ b/vcl/source/outdev/font.cxx
@@ -770,16 +770,19 @@ size_t ImplFontCache::IFSD_Hash::operator()( const FontSelectPattern& rFSD ) con
 size_t FontSelectPatternAttributes::hashCode() const
 {
     // TODO: does it pay off to improve this hash function?
-    static FontNameHash aFontNameHash;
-    size_t nHash = aFontNameHash( maSearchName );
+    size_t nHash;
 #if ENABLE_GRAPHITE
     // check for features and generate a unique hash if necessary
     if (maTargetName.indexOf(grutils::GrFeatureParser::FEAT_PREFIX)
         != -1)
     {
-        nHash = aFontNameHash( maTargetName );
+        nHash = maTargetName.hashCode();
     }
+    else
 #endif
+    {
+        nHash = maSearchName.hashCode();
+    }
     nHash += 11 * mnHeight;
     nHash += 19 * GetWeight();
     nHash += 29 * GetSlant();


More information about the Libreoffice-commits mailing list