summaryrefslogtreecommitdiff
path: root/Build/source/texk/web2c/xetexdir/FontTableCache.cpp
diff options
context:
space:
mode:
authorJonathan Kew <jfkthame@googlemail.com>2008-02-15 13:15:05 +0000
committerJonathan Kew <jfkthame@googlemail.com>2008-02-15 13:15:05 +0000
commit8ffd652f16549581f95dc60a3f383774a6df2e5d (patch)
treef9c1b0c48ec300c602ec2c89de8d2797b4046f4c /Build/source/texk/web2c/xetexdir/FontTableCache.cpp
parente814a390ac12149e9d6a37d07cb403373de34ccb (diff)
sync with xetex repos. rev 572
git-svn-id: svn://tug.org/texlive/trunk@6636 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/web2c/xetexdir/FontTableCache.cpp')
-rw-r--r--Build/source/texk/web2c/xetexdir/FontTableCache.cpp47
1 files changed, 22 insertions, 25 deletions
diff --git a/Build/source/texk/web2c/xetexdir/FontTableCache.cpp b/Build/source/texk/web2c/xetexdir/FontTableCache.cpp
index 1e2a6c4237b..66636607c52 100644
--- a/Build/source/texk/web2c/xetexdir/FontTableCache.cpp
+++ b/Build/source/texk/web2c/xetexdir/FontTableCache.cpp
@@ -66,12 +66,6 @@ FontTableCache::initialize()
fTableCacheSize = 0;
return;
}
-
- for (int i = 0; i < fTableCacheSize; i += 1) {
- fTableCache[i].tag = 0;
- fTableCache[i].table = NULL;
- fTableCache[i].size = 0;
- }
}
FontTableCache::~FontTableCache()
@@ -83,10 +77,6 @@ void FontTableCache::dispose()
{
for (int i = fTableCacheCurr - 1; i >= 0; i -= 1) {
LE_DELETE_ARRAY(fTableCache[i].table);
-
- fTableCache[i].tag = 0;
- fTableCache[i].table = NULL;
- fTableCache[i].size = 0;
}
fTableCacheCurr = 0;
@@ -94,13 +84,20 @@ void FontTableCache::dispose()
const void *FontTableCache::find(LETag tableTag, le_uint32 *tableSize) const
{
- for (int i = 0; i < fTableCacheCurr; i += 1) {
- if (fTableCache[i].tag == tableTag) {
+ int lo = 0, hi = fTableCacheCurr;
+ while (lo < hi) {
+ int i = (lo + hi) >> 1;
+ const FontTableCacheEntry *e = fTableCache + i;
+ if (e->tag < tableTag)
+ lo = i + 1;
+ else if (e->tag > tableTag)
+ hi = i;
+ else {
if (tableSize != NULL)
- *tableSize = fTableCache[i].size;
- return fTableCache[i].table;
- }
- }
+ *tableSize = e->size;
+ return e->table;
+ }
+ }
le_uint32 length;
const void *table = readFontTable(tableTag, length);
@@ -119,18 +116,18 @@ void FontTableCache::add(LETag tableTag, const void *table, le_uint32 length)
fTableCache = (FontTableCacheEntry *) LE_GROW_ARRAY(fTableCache, newSize);
- for (le_int32 i = fTableCacheSize; i < newSize; i += 1) {
- fTableCache[i].tag = 0;
- fTableCache[i].table = NULL;
- fTableCache[i].size = 0;
- }
-
fTableCacheSize = newSize;
}
- fTableCache[fTableCacheCurr].tag = tableTag;
- fTableCache[fTableCacheCurr].table = table;
- fTableCache[fTableCacheCurr].size = length;
+ int i;
+ for (i = fTableCacheCurr; i > 0; --i) {
+ if (fTableCache[i-1].tag < tableTag)
+ break;
+ fTableCache[i] = fTableCache[i-1];
+ }
+ fTableCache[i].tag = tableTag;
+ fTableCache[i].table = table;
+ fTableCache[i].size = length;
fTableCacheCurr += 1;
}