On 03/05/15 09:56, Akira TAGOH wrote:
just committed the change. that should works better now.
Yup it's fast again now... but:
FcBool
FcBlanksIsMember (FcBlanks *b, FcChar32 ucs4)
{
- int i;
+ int lower = 0, higher = b->nblank, middle;
- for (i = 0; i < b->nblank; i++)
- if (b->blanks[i] == ucs4)
+ if (b->nblank == 0 ||
+ b->blanks[0] > ucs4 ||
+ b->blanks[b->nblank - 1] < ucs4)
+ return FcFalse;
+ while (1)
+ {
+ middle = (lower + higher) / 2;
+ if (b->blanks[middle] == ucs4)
return FcTrue;
+ if (middle == lower ||
+ middle == higher)
wouldn't this need to be:
if (lower == higher)
Rationale:
If lower and higher are 1 apart, one bound will be checked, but not the
other. For the current list of blanks and my font cache, I observed the
following with ucs4==0xfe07 (which is /in/ the list):
sun2:fontconfig)dbx `which fc-cache`
[...]
(dbx) runargs -f
(dbx) stop at fcblanks.c:93 -if higher-lower==1 && ucs4==0xfe07
(2) stop at "fcblanks.c":93 -if higher-lower == 1 && ucs4 == 0xfe07
(dbx) run
Running: fc-cache -f
(process id 22766)
t@1 (l@1) stopped in FcBlanksIsMember at line 93 in file "fcblanks.c"
93 middle = (lower + higher) / 2;
(dbx) next
t@1 (l@1) stopped in FcBlanksIsMember at line 94 in file "fcblanks.c"
94 if (b->blanks[middle] == ucs4)
(dbx) print lower,middle,higher,b->blanks[middle],b->blanks[higher],ucs4
lower = 62
middle = 62
higher = 63
b->blanks[middle] = 65030U
b->blanks[higher] = 65031U
ucs4 = 65031U
(dbx) next
t@1 (l@1) stopped in FcBlanksIsMember at line 97 in file "fcblanks.c"
97 middle == higher)
(dbx) next
t@1 (l@1) stopped in FcBlanksIsMember at line 98 in file "fcblanks.c"
98 break;
(dbx) next
t@1 (l@1) stopped in FcBlanksIsMember at line 105 in file "fcblanks.c"
105 return FcFalse;
--
Worringer Str 31 Duesseldorf 40211 DE home: <rs@xxxxxxxx>
+49-179-2981632 icq 16845346 work: <rs@xxxxxxxxxxxxxxx>
_______________________________________________
Fontconfig mailing list
Fontconfig@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/fontconfig