bug 752394 followup - no need to use an nsString for a single character. r=jdaggett

This commit is contained in:
Jonathan Kew 2014-05-01 08:53:08 +01:00
Родитель 7379d4f0aa
Коммит 3167d4062a
1 изменённых файлов: 8 добавлений и 12 удалений

Просмотреть файл

@ -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;