Kaydet (Commit) d67da1e7 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Remove FontNameHash, use standard OUStringHash

Change-Id: If123bbe8a4ee044ef45f418be0118ccf9509f4e7
üst bcbf14f6
......@@ -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
......
......@@ -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;
......
......@@ -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
......
......@@ -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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment