This is not a bug report but a suggestion for improvement. FcSortWalk() does unnecessary check of charset even if called with trim==FcFlase. I think it should have one more arg "FcBool check_cs", and build up charset only when trim==FcTrue || check_cs==FcTrue. And FcFontSetSort() should call it with check_cs==FcTrue only when csp!=NULL.
Created attachment 5272 [details] [review] Don't copy FcCharSet if we're going to chuck it anyway. This is just a bit tricky, so I'm sleeping on this patch before committing it.
Good thing I slept on it, I had an extra ! in there... Copying a charset is cheap, but doing charset union is potentially expensive. Not sure how much we save here. Anyway, I've committed the fixed patch.
Thank you for the fix. Previously, FcFontSort without trimming was more than 10 times slower than with trimming. But now they run in almost the same speed. It seems that the overhead of building big fontset is compatible with the overhead of many charset union. This is the program I used for confirming it. #include <stdio.h> #include <stdlib.h> #include <string.h> #include <fontconfig/fontconfig.h> int main (int argc, char **argv) { int i; FcPattern *pat; FcFontSet *fs; FcResult result; FcBool trim; FcInit (); pat = FcPatternCreate (); FcPatternAddInteger (pat, FC_WEIGHT, FC_WEIGHT_MEDIUM); FcPatternAddInteger (pat, FC_SLANT, FC_SLANT_ROMAN); FcPatternAddInteger (pat, FC_WIDTH, FC_WIDTH_NORMAL); trim = (argc > 1 && strcmp (argv[1], "trim") == 0) ? FcTrue : FcFalse; for (i = 0; i < 10; i++) { fs = FcFontSort (NULL, pat, trim, NULL, &result); FcFontSetDestroy (fs); } exit (0); }
Thanks!
Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.