changeset 46169:36989d5089ee

2002-07-03 Andrew Choi <akochoi@shaw.ca> * macterm.c (x_list_fonts): Fix comment. Cache fonts matching pattern. Search cache first.
author Andrew Choi <akochoi@shaw.ca>
date Thu, 04 Jul 2002 02:43:48 +0000
parents 56be68853618
children 115fa2a7cd26
files src/ChangeLog src/macterm.c
diffstat 2 files changed, 30 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Thu Jul 04 02:10:45 2002 +0000
+++ b/src/ChangeLog	Thu Jul 04 02:43:48 2002 +0000
@@ -1,7 +1,9 @@
 2002-07-03  Andrew Choi  <akochoi@shaw.ca>
 
-	* macterm.c (init_font_name_table): Also add entry for
-	jisx0201.1976-0 coding for Japanese font.
+	* macterm.c (x_list_fonts): Fix comment.  Cache fonts matching
+	pattern.  Search cache first.
+	(init_font_name_table): Also add entry for jisx0201.1976-0 coding
+	for Japanese font.
 	(XLoadQueryFont): Use it.
 
 2002-07-02  Richard M. Stallman  <rms@gnu.org>
--- a/src/macterm.c	Thu Jul 04 02:10:45 2002 +0000
+++ b/src/macterm.c	Thu Jul 04 02:43:48 2002 +0000
@@ -10860,11 +10860,9 @@
 
 
 /* Return a list of at most MAXNAMES font specs matching the one in
-   PATTERN.  Note that each '*' in the PATTERN matches exactly one
-   field of the font spec, unlike X in which an '*' in a font spec can
-   match a number of fields.  The result is in the Mac implementation
-   all fonts must be specified by a font spec with all 13 fields
-   (although many of these can be "*'s").  */
+   PATTERN.  Cache matching fonts for patterns in
+   dpyinfo->name_list_element to avoid looking them up again by
+   calling mac_font_pattern_match (slow).  */
 
 Lisp_Object
 x_list_fonts (struct frame *f,
@@ -10873,14 +10871,28 @@
               int maxnames)
 {
   char *ptnstr;
-  Lisp_Object newlist = Qnil;
+  Lisp_Object newlist = Qnil, tem, key;
   int n_fonts = 0;
   int i;
   struct gcpro gcpro1, gcpro2;
+  struct mac_display_info *dpyinfo = f ? FRAME_MAC_DISPLAY_INFO (f) : NULL;
 
   if (font_name_table == NULL)  /* Initialize when first used.  */
     init_font_name_table ();
 
+  if (dpyinfo)
+    {
+      tem = XCDR (dpyinfo->name_list_element);
+      key = Fcons (pattern, make_number (maxnames));
+
+      newlist = Fassoc (key, tem);
+      if (!NILP (newlist))
+	{
+	  newlist = Fcdr_safe (newlist);
+	  goto label_cached;
+	}
+    }
+
   ptnstr = XSTRING (pattern)->data;
 
   GCPRO2 (pattern, newlist);
@@ -10902,6 +10914,14 @@
 
   UNGCPRO;
 
+  if (dpyinfo)
+    {
+      XSETCDR (dpyinfo->name_list_element,
+	       Fcons (Fcons (key, newlist),
+		      XCDR (dpyinfo->name_list_element)));
+    }
+ label_cached:
+  
   return newlist;
 }