diff src/chartab.h @ 1296:87084e8445a7

[xemacs-hg @ 2003-02-14 09:50:15 by ben] syntax-table fixes 1. the updating of mirror tables every time a syntax table was modified was taking up huge amounts of time so i added a dirty flag and made the updating "just-in-time". 2. no-longer-used char-table-entries were not getting "freed", generating tons of garbage. 3. syntax_match() was being incorrectly called on mirror tables in the cache, not the original syntax table. buffer.c, syntax.c: Move syntax table description from buffer.c to syntax.c. chartab.c, chartab.h: Free extra char table entries to avoid excessive garbage. Add flags for dirty and mirror_table_p to char tables. Add a back pointer from mirror tables to the original syntax table. When modifying a syntax table, don't update the mirror table right away, just mark as dirty. Add various asserts to make sure we are dealing with the right type of table (mirror or non-mirror). font-lock.c, syntax.c, syntax.h: Add entry to syntax caches for the non-mirror table. Set it appropriately when initializing the syntax table. Use it, not the mirror table, for calls to syntax_match(). Don't create a bogus float each time, just once at startup. Add some asserts, as in chartab.c. syntax.h: When retrieving the syntax code, check the dirty flag and update the mirror tables as appropriate. Add some asserts, as above.
author ben
date Fri, 14 Feb 2003 09:50:17 +0000
parents 804517e16990
children 6fa9919a9a0b
line wrap: on
line diff
--- a/src/chartab.h	Fri Feb 14 07:54:29 2003 +0000
+++ b/src/chartab.h	Fri Feb 14 09:50:17 2003 +0000
@@ -1,7 +1,7 @@
 /* Declarations having to do with Mule char tables.
    Copyright (C) 1992 Free Software Foundation, Inc.
    Copyright (C) 1995 Sun Microsystems, Inc.
-   Copyright (C) 2002 Ben Wing.
+   Copyright (C) 2002, 2003 Ben Wing.
 
 This file is part of XEmacs.
 
@@ -119,8 +119,12 @@
   enum char_table_type type;
 
   /* stuff used for syntax tables */
-  Lisp_Object mirror_table;
+  Lisp_Object mirror_table; /* points to mirror table for this table
+			       (a cache for quicker access), or a back
+			       pointer if MIRROR_TABLE_P. */
   Lisp_Object next_table; /* DO NOT mark through this. */
+  char dirty; /* nonzero if mirror dirty and needs updating. */
+  char mirror_table_p; /* nonzero if this is a mirror table. */
 };
 typedef struct Lisp_Char_Table Lisp_Char_Table;
 
@@ -140,7 +144,7 @@
 
 DECLARE_INLINE_HEADER (
 Lisp_Object
-get_char_table (Ichar ch, Lisp_Object table)
+get_char_table_1 (Ichar ch, Lisp_Object table)
 )
 {
   Lisp_Object retval;
@@ -165,6 +169,19 @@
     return ct->default_;
 }
 
+#ifdef ERROR_CHECK_TYPES
+DECLARE_INLINE_HEADER (
+Lisp_Object
+get_char_table (Ichar ch, Lisp_Object table)
+)
+{
+  assert (!XCHAR_TABLE (table)->mirror_table_p);
+  return get_char_table_1 (ch, table);
+}
+#else
+#define get_char_table(ch, table) get_char_table_1 (ch, table)
+#endif
+
 enum chartab_range_type
 {
   CHARTAB_RANGE_ALL,
@@ -195,6 +212,13 @@
 void prune_syntax_tables (void);
 Lisp_Object get_range_char_table (struct chartab_range *range,
 				  Lisp_Object table, Lisp_Object multi);
+#ifdef ERROR_CHECK_TYPES
+Lisp_Object updating_mirror_get_range_char_table (struct chartab_range *range,
+						  Lisp_Object table,
+						  Lisp_Object multi);
+#else
+#define updating_mirror_get_range_char_table get_range_char_table
+#endif
 void copy_char_table_range (Lisp_Object from, Lisp_Object to,
 			    struct chartab_range *range);
 int word_boundary_p (Ichar c1, Ichar c2);