comparison 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
comparison
equal deleted inserted replaced
1295:064ef1d07d63 1296:87084e8445a7
1 /* Declarations having to do with Mule char tables. 1 /* Declarations having to do with Mule char tables.
2 Copyright (C) 1992 Free Software Foundation, Inc. 2 Copyright (C) 1992 Free Software Foundation, Inc.
3 Copyright (C) 1995 Sun Microsystems, Inc. 3 Copyright (C) 1995 Sun Microsystems, Inc.
4 Copyright (C) 2002 Ben Wing. 4 Copyright (C) 2002, 2003 Ben Wing.
5 5
6 This file is part of XEmacs. 6 This file is part of XEmacs.
7 7
8 XEmacs is free software; you can redistribute it and/or modify it 8 XEmacs is free software; you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published by the 9 under the terms of the GNU General Public License as published by the
117 #endif /* MULE */ 117 #endif /* MULE */
118 118
119 enum char_table_type type; 119 enum char_table_type type;
120 120
121 /* stuff used for syntax tables */ 121 /* stuff used for syntax tables */
122 Lisp_Object mirror_table; 122 Lisp_Object mirror_table; /* points to mirror table for this table
123 (a cache for quicker access), or a back
124 pointer if MIRROR_TABLE_P. */
123 Lisp_Object next_table; /* DO NOT mark through this. */ 125 Lisp_Object next_table; /* DO NOT mark through this. */
126 char dirty; /* nonzero if mirror dirty and needs updating. */
127 char mirror_table_p; /* nonzero if this is a mirror table. */
124 }; 128 };
125 typedef struct Lisp_Char_Table Lisp_Char_Table; 129 typedef struct Lisp_Char_Table Lisp_Char_Table;
126 130
127 DECLARE_LRECORD (char_table, Lisp_Char_Table); 131 DECLARE_LRECORD (char_table, Lisp_Char_Table);
128 #define XCHAR_TABLE(x) XRECORD (x, char_table, Lisp_Char_Table) 132 #define XCHAR_TABLE(x) XRECORD (x, char_table, Lisp_Char_Table)
138 int leading_byte, 142 int leading_byte,
139 Ichar c); 143 Ichar c);
140 144
141 DECLARE_INLINE_HEADER ( 145 DECLARE_INLINE_HEADER (
142 Lisp_Object 146 Lisp_Object
143 get_char_table (Ichar ch, Lisp_Object table) 147 get_char_table_1 (Ichar ch, Lisp_Object table)
144 ) 148 )
145 { 149 {
146 Lisp_Object retval; 150 Lisp_Object retval;
147 Lisp_Char_Table *ct = XCHAR_TABLE (table); 151 Lisp_Char_Table *ct = XCHAR_TABLE (table);
148 #ifdef MULE 152 #ifdef MULE
163 return retval; 167 return retval;
164 else 168 else
165 return ct->default_; 169 return ct->default_;
166 } 170 }
167 171
172 #ifdef ERROR_CHECK_TYPES
173 DECLARE_INLINE_HEADER (
174 Lisp_Object
175 get_char_table (Ichar ch, Lisp_Object table)
176 )
177 {
178 assert (!XCHAR_TABLE (table)->mirror_table_p);
179 return get_char_table_1 (ch, table);
180 }
181 #else
182 #define get_char_table(ch, table) get_char_table_1 (ch, table)
183 #endif
184
168 enum chartab_range_type 185 enum chartab_range_type
169 { 186 {
170 CHARTAB_RANGE_ALL, 187 CHARTAB_RANGE_ALL,
171 #ifdef MULE 188 #ifdef MULE
172 CHARTAB_RANGE_CHARSET, 189 CHARTAB_RANGE_CHARSET,
193 Lisp_Object val, void *arg), 210 Lisp_Object val, void *arg),
194 void *arg); 211 void *arg);
195 void prune_syntax_tables (void); 212 void prune_syntax_tables (void);
196 Lisp_Object get_range_char_table (struct chartab_range *range, 213 Lisp_Object get_range_char_table (struct chartab_range *range,
197 Lisp_Object table, Lisp_Object multi); 214 Lisp_Object table, Lisp_Object multi);
215 #ifdef ERROR_CHECK_TYPES
216 Lisp_Object updating_mirror_get_range_char_table (struct chartab_range *range,
217 Lisp_Object table,
218 Lisp_Object multi);
219 #else
220 #define updating_mirror_get_range_char_table get_range_char_table
221 #endif
198 void copy_char_table_range (Lisp_Object from, Lisp_Object to, 222 void copy_char_table_range (Lisp_Object from, Lisp_Object to,
199 struct chartab_range *range); 223 struct chartab_range *range);
200 int word_boundary_p (Ichar c1, Ichar c2); 224 int word_boundary_p (Ichar c1, Ichar c2);
201 225
202 EXFUN (Fcopy_char_table, 1); 226 EXFUN (Fcopy_char_table, 1);