diff --git a/src/fcblanks.c b/src/fcblanks.c index 49f520b..f163a8f 100644 --- a/src/fcblanks.c +++ b/src/fcblanks.c @@ -82,11 +82,26 @@ FcBlanksAdd (FcBlanks *b, FcChar32 ucs4) 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) + break; + if (b->blanks[middle] < ucs4) + lower = middle + 1; + else + higher = middle - 1; + } + return FcFalse; } #define __fcblanks__