From 3167d4062a21da20a9f6f3f6a6469d92106c17ca Mon Sep 17 00:00:00 2001 From: Jonathan Kew Date: Thu, 1 May 2014 08:53:08 +0100 Subject: [PATCH] bug 752394 followup - no need to use an nsString for a single character. r=jdaggett --- gfx/thebes/gfxPlatformFontList.cpp | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/gfx/thebes/gfxPlatformFontList.cpp b/gfx/thebes/gfxPlatformFontList.cpp index 6a93ea5e2492..4888673afeee 100644 --- a/gfx/thebes/gfxPlatformFontList.cpp +++ b/gfx/thebes/gfxPlatformFontList.cpp @@ -244,16 +244,17 @@ gfxPlatformFontList::InitOtherFamilyNamesProc(nsStringHashKey::KeyType aKey, struct ReadFaceNamesData { ReadFaceNamesData(gfxPlatformFontList *aFontList, TimeStamp aStartTime) - : mFontList(aFontList), mStartTime(aStartTime), mTimedOut(false) + : mFontList(aFontList), mStartTime(aStartTime), mTimedOut(false), + mFirstChar(0) {} gfxPlatformFontList *mFontList; TimeStamp mStartTime; bool mTimedOut; - // if mFirstChar is not empty, only load facenames for families + // if mFirstChar is not 0, only load facenames for families // that start with this character - nsString mFirstChar; + char16_t mFirstChar; }; gfxFontEntry* @@ -265,8 +266,7 @@ gfxPlatformFontList::SearchFamiliesForFaceName(const nsAString& aFaceName) ReadFaceNamesData faceNameListsData(this, start); // iterate over familes starting with the same letter - faceNameListsData.mFirstChar.Assign(aFaceName.CharAt(0)); - ToLowerCase(faceNameListsData.mFirstChar); + faceNameListsData.mFirstChar = ToLowerCase(aFaceName.CharAt(0)); mFontFamilies.Enumerate(gfxPlatformFontList::ReadFaceNamesProc, &faceNameListsData); lookup = FindFaceName(aFaceName); @@ -299,14 +299,10 @@ gfxPlatformFontList::ReadFaceNamesProc(nsStringHashKey::KeyType aKey, gfxPlatformFontList *fc = data->mFontList; // when filtering, skip names that don't start with the filter character - if (!(data->mFirstChar.IsEmpty())) { - char16_t firstChar = aKey.CharAt(0); - nsAutoString firstCharStr(&firstChar, 1); - ToLowerCase(firstCharStr); - if (!firstCharStr.Equals(data->mFirstChar)) { - return PL_DHASH_NEXT; - } + if (data->mFirstChar && ToLowerCase(aKey.CharAt(0)) != data->mFirstChar) { + return PL_DHASH_NEXT; } + aFamilyEntry->ReadFaceNames(fc, fc->NeedFullnamePostscriptNames()); TimeDuration elapsed = TimeStamp::Now() - data->mStartTime;