commit last fixes and optimisations to the cache manager.

The performance of cache hits has increased between 20 and 50% !!
This commit is contained in:
David Turner 2002-06-08 01:05:56 +00:00
parent f47d5f0b39
commit 4927e37a04
4 changed files with 31 additions and 19 deletions

View File

@ -21,7 +21,7 @@
/* define to allow cache lookup inlining */
#undef FTC_CACHE_USE_INLINE
#define FTC_CACHE_USE_INLINE
/* define to use linear hash table */
#define FTC_CACHE_USE_LINEAR_HASHING

View File

@ -257,8 +257,8 @@ FT_BEGIN_HEADER
/* */
/* Don't define any of these macros to compile in `release' mode! */
/* */
#define FT_DEBUG_LEVEL_ERROR
#define FT_DEBUG_LEVEL_TRACE
#undef FT_DEBUG_LEVEL_ERROR
#undef FT_DEBUG_LEVEL_TRACE
/*************************************************************************/
@ -273,7 +273,7 @@ FT_BEGIN_HEADER
/* Note that the memory debugger is only activated at runtime when */
/* when the _environment_ variable "FT_DEBUG_MEMORY" is also defined! */
/* */
#define FT_DEBUG_MEMORY
#undef FT_DEBUG_MEMORY
/*************************************************************************/

19
src/cache/ftccache.c vendored
View File

@ -23,10 +23,6 @@
#include "ftcerror.h"
/* define for level-1 optimisations */
#undef OPT1
#ifdef FTC_CACHE_USE_LINEAR_HASHING
@ -75,7 +71,9 @@
if ( first )
{
FTC_Node last = first->mru_prev;
FT_ASSERT( last->mru_next == first );
node->mru_prev = last;
node->mru_next = first;
@ -137,11 +135,12 @@
{
FTC_Node prev = node->mru_prev;
FTC_Node next = node->mru_next;
FTC_Node last = first->mru_prev;
FTC_Node last;
prev->mru_next = next;
next->mru_prev = prev;
last = first->mru_prev;
node->mru_next = first;
node->mru_prev = last;
first->mru_prev = node;
@ -741,7 +740,8 @@
query->hash = 0;
query->family = NULL;
#ifdef OPT1
/* XXX: we break encapsulation for the sake of speed !! */
#if 1
{
/* first of all, find the relevant family */
FT_LruList list = cache->families;
@ -827,14 +827,9 @@
if ( node == NULL )
break;
#ifdef OPT1
if ( node->hash == hash &&
(FT_UInt)node->fam_index == family->fam_index &&
compare( node, query, cache ) )
#else
if ( (FT_UInt)node->fam_index == family->fam_index &&
compare( node, query, cache ) )
#endif
{
/* move to head of bucket list */
if ( pnode != bucket )

23
src/cache/ftccmap.c vendored
View File

@ -318,6 +318,23 @@
}
#ifdef FTC_CACHE_USE_INLINE
# define GEN_CACHE_FAMILY_COMPARE(f,q,c) \
ftc_cmap_family_compare( (FTC_CMapFamily)(f), (FTC_CMapQuery)(q) )
# define GEN_CACHE_NODE_COMPARE(n,q,c) \
ftc_cmap_node_compare( (FTC_CMapNode)(n), (FTC_CMapQuery)(q) )
# define GEN_CACHE_LOOKUP ftc_cmap_cache_lookup
# include "ftccache.i"
#else /* !FTC_CACHE_USE_INLINE */
# define ftc_cmap_cache_lookup ftc_cache_lookup
#endif /* !FTC_CACHE_USE_INLINE */
/* documentation is in ftccmap.h */
FT_EXPORT_DEF( FT_UInt )
@ -340,9 +357,9 @@
cquery.desc = desc;
cquery.char_code = char_code;
error = ftc_cache_lookup( FTC_CACHE( cache ),
FTC_QUERY( &cquery ),
(FTC_Node*)&node );
error = ftc_cmap_cache_lookup( FTC_CACHE( cache ),
FTC_QUERY( &cquery ),
(FTC_Node*)&node );
if ( !error )
{
FT_UInt offset = (FT_UInt)( char_code - node->first );