Created attachment 632294 [details] [diff] [review]
optimize access to the mFonts array in gfxFontGroup
There's no reason for gfxFontGroup::FontListLength to be virtual; and we can reduce the overhead of accessing the mFonts array by getting the Length and Elements pointer into local variables instead of repeatedly using the nsTArray methods and GetFontAt() within loops.
Created attachment 634600 [details] [diff] [review]
patch, optimize common case in gfxFontGroup::FindFontForChar, and various other loops in font code
Extending this bug to cover more cases where we can optimize by pulling nsTArray::Length() accesses out of loops, etc., and more importantly, optimize gfxFontGroup::FindFontForChar by handling the most common case (a normal character available in the first font of the group) at the beginning of the function.
When reflowing the tinderbox log mentioned in bug 762710 comment 0 on my MBPro, this patch reduces the total time spent in gfxFontGroup::FindFontForChar (as recorded by Instruments) from about 650-700ms to around 260ms.