Re: Distinct performance issues with Japanese only on win32 systems



A few weeks ago I reported a performance issue regarding the use of
Uniscribe in the win32 basic shaper.

It turns out that the issue was with the use of Uniscribe's
SCRIPT_CACHE.  Despite the name, this value is for caching
per-font-plus-size values, not per-script values.  See:

  http://msdn.microsoft.com/en-us/library/dd317726(VS.85).aspx

Since shaping occurs on runs containing a single font, we only need
one SCRIPT_CACHE in uniscribe_shape.  I'm including a patch below that
does this.  With the patch applied, the time for one of my tests went
from 20s to .3s.

  --deh!


--- unpatched-pango/modules/basic/basic-win32.c	2009-07-30 23:47:43 +0000
+++ patched-pango/modules/basic/basic-win32.c	2009-08-10 23:34:29 +0000
@@ -581,7 +581,7 @@
 #endif
 
       items[item].a.fRTL = analysis->level % 2;
-      if ((*script_shape) (hdc, &script_cache[script],
+      if ((*script_shape) (hdc, script_cache,
 			   wtext + items[item].iCharPos, itemlen,
 			   G_N_ELEMENTS (iglyphs),
 			   &items[item].a,
@@ -611,7 +611,7 @@
 				 nglyphs, glyphs->log_clusters + ng,
 				 char_offset);
 
-      if ((*script_place) (hdc, &script_cache[script], iglyphs, nglyphs,
+      if ((*script_place) (hdc, script_cache, iglyphs, nglyphs,
 			   visattrs, &items[item].a,
 			   advances, offsets, &abc))
 	{
@@ -673,7 +673,7 @@
   long wlen;
   int i;
   gboolean retval = TRUE;
-  SCRIPT_CACHE script_cache[100];
+  SCRIPT_CACHE script_cache;
 
   if (!pango_win32_font_select_font (font, hdc))
     return FALSE;
@@ -684,11 +684,10 @@
 
   if (retval)
     {
-      memset (script_cache, 0, sizeof (script_cache));
+      memset (&script_cache, 0, sizeof (script_cache));
       retval = itemize_shape_and_place (font, hdc, wtext, wlen, analysis, glyphs, script_cache);
-      for (i = 0; i < G_N_ELEMENTS (script_cache); i++)
-	if (script_cache[i])
-	  (*script_free_cache)(&script_cache[i]);
+      if (script_cache)
+	  (*script_free_cache)(&script_cache);
     }
 
   if (retval)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]