pango should optimize away calls to FcFontSort as much as possible
Submitted by L. David Baron
Link to original bug (#348825)
Description
Please describe the problem: A performance problem that affects Mozilla's use of pango is that pango unconditionally calls FcFontSort when choosing what font to use. I believe this call is O(N log N) in the number of fonts on the system. What pango does with the result of this call is presumably looking for glyphs in the fonts starting with the first font return -- so in many cases it only needs the very first font in the list returned, which can be retrieved in O(N) time with FcFontMatch.
Mozilla's existing (pre-pango) direct use of Xft has an optimization that first calls FcFontMatch to get the first-choice font, and then only calls FcFontSort if it needs to look past the first-choice, which in many cases is a relatively rare event.
For more details, see:
https://bugzilla.mozilla.org/show_bug.cgi?id=334064 - this describes the performance problems caused by this issue. Note that these problems will be worked around significantly for the Western case by adding ASCII fast paths in Mozilla.
https://bugzilla.mozilla.org/show_bug.cgi?id=223813 - the bug where Mozilla made similar optimizations
Steps to reproduce:
Actual results:
Expected results:
Does this happen every time?
Other information:
Version: 1.12.x