shithub: freetype+ttf2subf

Download patch

ref: 4927e37a042368fa7c2657aaa26ed98fb72dfacc
parent: f47d5f0b39f130c3d9d297f64fef2ef3a5635349
author: David Turner <[email protected]>
date: Fri Jun 7 21:05:56 EDT 2002

commit last fixes and optimisations to the cache manager.
The performance of cache hits has increased between 20 and 50% !!

git/fs: mount .git/fs: mount/attach disallowed
--- a/include/freetype/cache/ftccache.h
+++ b/include/freetype/cache/ftccache.h
@@ -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
--- a/include/freetype/config/ftoption.h
+++ b/include/freetype/config/ftoption.h
@@ -257,8 +257,8 @@
   /*                                                                       */
   /*   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 @@
   /*   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
 
 
   /*************************************************************************/
--- a/src/cache/ftccache.c
+++ b/src/cache/ftccache.c
@@ -23,11 +23,7 @@
 
 #include "ftcerror.h"
 
-/* define for level-1 optimisations */
-#undef   OPT1
 
-
-
 #ifdef FTC_CACHE_USE_LINEAR_HASHING
 
 #define  FTC_HASH_MAX_LOAD  2
@@ -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 )
--- a/src/cache/ftccmap.c
+++ b/src/cache/ftccmap.c
@@ -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 );