fixed a small performance bug in the new cache sub-system implementation
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
diff --git a/ChangeLog b/ChangeLog
index dfcf778..1a3d575 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2001-10-27 David Turner <david@freetype.org>
+
+ * src/cache/ftchunk.c (ftc_chunk_cache_lookup): fixed a bug that
+ considerably lowered the performance of the abstract chunk cache.
+
2001-10-26 David Turner <david@freetype.org>
* include/freetype/ftcache.h, include/freetype/cache/*.h,
diff --git a/src/cache/ftcchunk.c b/src/cache/ftcchunk.c
index 9fc08af..e6288bc 100644
--- a/src/cache/ftcchunk.c
+++ b/src/cache/ftcchunk.c
@@ -34,8 +34,15 @@
/*************************************************************************/
/*************************************************************************/
-#define FTC_CSET_HASH(cset,start) \
- ((FT_UFast)(((cset)->hash << 16) | ((start) & 0xFFFF)))
+#define FTC_CSET_CHUNK_INDEX(cset,gindex) \
+ ( (gindex) / (cset)->item_count )
+
+#define FTC_CSET_START(cset,gindex) \
+ ( FTC_CSET_CHUNK_INDEX(cset,gindex) * (cset)->item_count )
+
+#define FTC_CSET_HASH(cset,gindex) \
+ ((FT_UFast)( ((cset)->hash << 16) | \
+ (FTC_CSET_CHUNK_INDEX(cset,gindex) & 0xFFFF) ))
/* create a new chunk node, setting its cache index and ref count */
FT_EXPORT_DEF( FT_Error )
@@ -47,10 +54,10 @@
FTC_ChunkCache ccache = cset->ccache;
FT_Error error = 0;
FT_UInt len;
- FT_UInt start = (gindex / cset->item_count) * cset->item_count;
+ FT_UInt start = FTC_CSET_START(cset,gindex);
cnode->cset = cset;
- cnode->node.hash = FTC_CSET_HASH(cset,start);
+ cnode->node.hash = FTC_CSET_HASH(cset,gindex);
cnode->item_start = start;
len = cset->item_total - start;
@@ -149,6 +156,7 @@
}
+
FT_EXPORT_DEF( FT_Error )
ftc_chunk_cache_init( FTC_ChunkCache ccache,
FT_LruList_Class cset_class )
@@ -166,6 +174,7 @@
}
+
FT_EXPORT_DEF( FT_Error )
ftc_chunk_cache_lookup( FTC_ChunkCache ccache,
FTC_ChunkQuery query,
@@ -177,8 +186,8 @@
error = FT_LruList_Lookup( ccache->cset_lru, query, &node );
if ( !error )
{
- FTC_ChunkSet cset = FTC_CHUNK_SET(node);
- FT_UFast hash = FTC_CSET_HASH( cset, query->gindex );
+ FTC_ChunkSet cset = FTC_CHUNK_SET(node);
+ FT_UFast hash = FTC_CSET_HASH( cset, query->gindex );
error = ftc_cache_lookup_node( FTC_CACHE(ccache), hash, query,
FTC_NODE_P(anode) );
diff --git a/src/cache/ftcsbits.c b/src/cache/ftcsbits.c
index 871c20c..95b5a13 100644
--- a/src/cache/ftcsbits.c
+++ b/src/cache/ftcsbits.c
@@ -225,7 +225,7 @@
/* now, compute size */
if ( asize )
- *asize = sizeof( FTC_SBitRec ) + ABS(sbit->pitch) * sbit->height;
+ *asize = ABS(sbit->pitch) * sbit->height;
} /* glyph dimensions ok */