bug 752394 followup - no need to use an nsString for a single character. r=jdaggett
authorJonathan Kew <jkew@mozilla.com>
Thu, 01 May 2014 08:53:08 +0100
changeset 181550 7118f282f343f7390d1dce0f9c0a0b3bb8274b7f
parent 181549 57ed333a91f15029b65ccafc6f93fe7334a72b5b
child 181551 293ecda82136f86fb5605aeea6b3df2eccec3775
push id272
push userpvanderbeken@mozilla.com
push dateMon, 05 May 2014 16:31:18 +0000
reviewersjdaggett
bugs752394
milestone32.0a1
bug 752394 followup - no need to use an nsString for a single character. r=jdaggett
gfx/thebes/gfxPlatformFontList.cpp
--- a/gfx/thebes/gfxPlatformFontList.cpp
+++ b/gfx/thebes/gfxPlatformFontList.cpp
@@ -239,39 +239,39 @@ gfxPlatformFontList::InitOtherFamilyName
         data->mTimedOut = true;
         return PL_DHASH_STOP;
     }
     return PL_DHASH_NEXT;
 }
  
 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*
 gfxPlatformFontList::SearchFamiliesForFaceName(const nsAString& aFaceName)
 {
     TimeStamp start = TimeStamp::Now();
     gfxFontEntry *lookup = nullptr;
 
     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);
 
     TimeStamp end = TimeStamp::Now();
     Telemetry::AccumulateTimeDelta(Telemetry::FONTLIST_INITFACENAMELISTS,
                                    start, end);
 #ifdef PR_LOGGING
@@ -294,24 +294,20 @@ PLDHashOperator
 gfxPlatformFontList::ReadFaceNamesProc(nsStringHashKey::KeyType aKey,
                                        nsRefPtr<gfxFontFamily>& aFamilyEntry,
                                        void* userArg)
 {
     ReadFaceNamesData *data = static_cast<ReadFaceNamesData*>(userArg);
     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;
     if (elapsed.ToMilliseconds() > NAMELIST_TIMEOUT) {
         data->mTimedOut = true;
         return PL_DHASH_STOP;
     }
     return PL_DHASH_NEXT;