]> git.wh0rd.org - fontconfig.git/commitdiff
Add letter ranges to speed lang lookups, change CVS tag
authorKeith Packard <keithp@keithp.com>
Wed, 5 Mar 2003 05:48:53 +0000 (05:48 +0000)
committerKeith Packard <keithp@keithp.com>
Wed, 5 Mar 2003 05:48:53 +0000 (05:48 +0000)
fc-lang/fc-lang.c
fc-lang/fc-lang.man
fc-lang/fclang.tmpl.h

index da4b3ed36d7990bbb553118ce911676a0fd6e6e5..7e76c4742267dcc05b25e9e987fd95a6307a38da 100644 (file)
@@ -1,7 +1,7 @@
 /*
- * $XFree86: xc/lib/fontconfig/fc-lang/fc-lang.c,v 1.3 2002/08/22 07:36:43 keithp Exp $
+ * $RCSId: xc/lib/fontconfig/fc-lang/fc-lang.c,v 1.3 2002/08/22 07:36:43 keithp Exp $
  *
- * Copyright © 2002 Keith Packard, member of The XFree86 Project, Inc.
+ * Copyright © 2002 Keith Packard
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
@@ -207,6 +207,9 @@ main (int argc, char **argv)
     char       line[1024];
     FcChar32   map[MAX_LANG_SET_MAP];
     int                num_lang_set_map;
+    int                setRangeStart[26];
+    int                setRangeEnd[26];
+    FcChar8    setRangeChar;
     
     while (*++argv)
     {
@@ -299,6 +302,21 @@ main (int argc, char **argv)
            }
     }
 
+    /*
+     * Find ranges for each letter for faster searching
+     */
+    setRangeChar = 'a';
+    for (i = 0; sets[i]; i++)
+    {
+       char    c = names[i][0];
+       
+       while (setRangeChar <= c && c <= 'z')
+           setRangeStart[setRangeChar++ - 'a'] = i;
+    }
+    for (setRangeChar = 'a'; setRangeChar < 'z'; setRangeChar++)
+       setRangeEnd[setRangeChar - 'a'] = setRangeStart[setRangeChar+1-'a'] - 1;
+    setRangeEnd[setRangeChar - 'a'] = i - 1;
+    
     /*
      * Dump arrays
      */
@@ -343,13 +361,16 @@ main (int argc, char **argv)
        printf ("};\n\n");
     }
     printf ("#undef L\n\n");
+    
     /*
      * Dump sets
      */
+
     printf ("static const FcLangCharSet  fcLangCharSets[] = {\n");
     for (i = 0; sets[i]; i++)
     {
        int     j = duplicate[i];
+
        if (j < 0)
            j = i;
        printf ("    { (FcChar8 *) \"%s\",\n"
@@ -404,6 +425,19 @@ main (int argc, char **argv)
        printf ("#define NUM_COUNTRY_SET %d\n", ncountry_ent);
     }
     
+
+    /*
+     * Dump sets start/finish for the fastpath
+     */
+    printf ("static const FcLangCharSetRange  fcLangCharSetRanges[] = {\n");
+    for (setRangeChar = 'a'; setRangeChar <= 'z' ; setRangeChar++)
+    {
+       printf ("    { %d, %d }, /* %c */\n",
+               setRangeStart[setRangeChar - 'a'],
+               setRangeEnd[setRangeChar - 'a'], setRangeChar);
+    }
+    printf ("};\n\n");
     while (fgets (line, sizeof (line), stdin))
        fputs (line, stdout);
     
index 782fb4174d771765af8f0c50c88ca621a1664aef..1eda09367b0b3b8cc74389cedf38db9e6daac4e0 100644 (file)
@@ -1,5 +1,5 @@
 .\"
-.\" Copyright © 2002 Keith Packard, member of The XFree86 Project, Inc.
+.\" Copyright © 2002 Keith Packard
 .\"
 .\" Permission to use, copy, modify, distribute, and sell this software and its
 .\" documentation for any purpose is hereby granted without fee, provided that
@@ -20,7 +20,7 @@
 .\" PERFORMANCE OF THIS SOFTWARE.
 .\"
 .\"
-.\" $XFree86: xc/programs/fc-lang/fc-lang.man,v 1.3 2001/02/09 03:47:56 tsi Exp $
+.\" $RCSId: xc/programs/fc-lang/fc-lang.man,v 1.3 2001/02/09 03:47:56 tsi Exp $
 .\"
 .TH FC-LANG 1 __vendorversion__
 .SH NAME
index a5a2d5a5cc0d7035e0cb4ae684eecdd2bfa7dac0..fdf243fe008310f068e8edb06185e779e645dde6 100644 (file)
@@ -1,7 +1,7 @@
 /*
- * $XFree86: xc/lib/fontconfig/fc-lang/fclang.tmpl.h,v 1.1 2002/07/06 23:21:36 keithp Exp $
+ * $RCSId: xc/lib/fontconfig/fc-lang/fclang.tmpl.h,v 1.1 2002/07/06 23:21:36 keithp Exp $
  *
- * Copyright © 2002 Keith Packard, member of The XFree86 Project, Inc.
+ * Copyright © 2002 Keith Packard
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that