From 0eadb052fb31ad99d77d1997108d316c64d939b8 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 5 Mar 2003 05:48:53 +0000 Subject: [PATCH] Add letter ranges to speed lang lookups, change CVS tag --- fc-lang/fc-lang.c | 38 ++++++++++++++++++++++++++++++++++++-- fc-lang/fc-lang.man | 4 ++-- fc-lang/fclang.tmpl.h | 4 ++-- 3 files changed, 40 insertions(+), 6 deletions(-) diff --git a/fc-lang/fc-lang.c b/fc-lang/fc-lang.c index da4b3ed..7e76c47 100644 --- a/fc-lang/fc-lang.c +++ b/fc-lang/fc-lang.c @@ -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); diff --git a/fc-lang/fc-lang.man b/fc-lang/fc-lang.man index 782fb41..1eda093 100644 --- a/fc-lang/fc-lang.man +++ b/fc-lang/fc-lang.man @@ -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 diff --git a/fc-lang/fclang.tmpl.h b/fc-lang/fclang.tmpl.h index a5a2d5a..fdf243f 100644 --- a/fc-lang/fclang.tmpl.h +++ b/fc-lang/fclang.tmpl.h @@ -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 -- 2.39.5