+2005-11-29 Dirk Mueller <dmueller@suse.de>
+ reviewed by: plam
+
+ * fc-lang/fc-lang.c:
+ * src/fccache.c (FcDirCacheConsume, FcCacheHaveBank,
+ FcCacheBankToIndex, FcCacheBankToIndexMTF,
+ FcCacheAddBankDir):
+ * src/fcint.h:
+
+ Refactor FcCacheBankToIndex into an inlineable part
+ (in fcint.h) which checks the front of the list and a
+ non-inlineable part which finds and moves the appropriate element
+ to the front of the list.
+
2005-11-29 Patrick Lam <plam@mit.edu>
* src/fccfg.c (FcConfigBuildFonts):
* src/fccache.c (FcCacheReadDirs):
PROT_READ, MAP_SHARED, fd, pos);
if (current_dir_block == MAP_FAILED)
return FcFalse;
-
- if (!FcFontSetUnserialize (&metadata, set, current_dir_block))
- return FcFalse;
FcCacheAddBankDir (metadata.bank, dir);
+ if (!FcFontSetUnserialize (&metadata, set, current_dir_block))
+ return FcFalse;
+
return FcTrue;
}
}
static int banks_ptr = 0, banks_alloc = 0;
-static int * bankId = 0, * bankIdx = 0;
+int * _fcBankId = 0, * _fcBankIdx = 0;
static const char ** bankDirs = 0;
static FcBool
return FcTrue;
for (i = 0; i < banks_ptr; i++)
- if (bankId[i] == bank)
+ if (_fcBankId[i] == bank)
return FcTrue;
return FcFalse;
}
int
-FcCacheBankToIndex (int bank)
+FcCacheBankToIndexMTF (int bank)
{
int i, j;
for (i = 0; i < banks_ptr; i++)
- if (bankId[bankIdx[i]] == bank)
+ if (_fcBankId[_fcBankIdx[i]] == bank)
{
- int t = bankIdx[i];
+ int t = _fcBankIdx[i];
for (j = i; j > 0; j--)
- bankIdx[j] = bankIdx[j-1];
- bankIdx[0] = t;
+ _fcBankIdx[j] = _fcBankIdx[j-1];
+ _fcBankIdx[0] = t;
return t;
}
int * b, * bidx;
const char ** bds;
- b = realloc (bankId, (banks_alloc + 4) * sizeof(int));
+ b = realloc (_fcBankId, (banks_alloc + 4) * sizeof(int));
if (!b)
return -1;
- bankId = b;
+ _fcBankId = b;
- bidx = realloc (bankIdx, (banks_alloc + 4) * sizeof(int));
+ bidx = realloc (_fcBankIdx, (banks_alloc + 4) * sizeof(int));
if (!bidx)
return -1;
- bankIdx = bidx;
+ _fcBankIdx = bidx;
bds = realloc (bankDirs, (banks_alloc + 4) * sizeof (char *));
if (!bds)
}
i = banks_ptr++;
- bankId[i] = bank;
- bankIdx[i] = i;
+ _fcBankId[i] = bank;
+ _fcBankIdx[i] = i;
return i;
}
static void
FcCacheAddBankDir (int bank, const char * dir)
{
- int bi = FcCacheBankToIndex (bank);
+ int bi = FcCacheBankToIndexMTF (bank);
if (bi < 0)
return;
FcBool
FcDirCacheRead (FcFontSet * set, FcStrSet * dirs, const FcChar8 *dir);
+extern int *_fcBankId, *_fcBankIdx;
int
-FcCacheBankToIndex (int bank);
+FcCacheBankToIndexMTF (int bank);
+
+static __inline__ int
+FcCacheBankToIndex (int bank)
+{
+ return _fcBankId[*_fcBankIdx] == bank ? *_fcBankIdx : FcCacheBankToIndexMTF(bank);
+}
const char *
FcCacheFindBankDir (int bank);