aboutsummaryrefslogtreecommitdiffstats
path: root/src/chartab.c
diff options
context:
space:
mode:
authorDmitry Antipov2014-07-02 07:26:19 +0400
committerDmitry Antipov2014-07-02 07:26:19 +0400
commit477daa5b533af8f62c9b6893e2d522b93d9c2853 (patch)
tree1dc2bb83f76ecfecbce218a9af3a2bf845f5e3b6 /src/chartab.c
parent1dc6f7e738e3ffe130626814f721c83c448fe9a8 (diff)
downloademacs-477daa5b533af8f62c9b6893e2d522b93d9c2853.tar.gz
emacs-477daa5b533af8f62c9b6893e2d522b93d9c2853.zip
Shrink Lisp_Sub_Char_Table by preferring C integers to Lisp_Objects.
* lisp.h (struct Lisp_Sub_Char_Table): Use C integers for depth and min_char slots. Adjust comment. (enum char_table_specials): Rename from CHAR_TABLE_STANDARD_SLOTS. Add SUB_CHAR_TABLE_OFFSET member. (make_uninit_sub_char_table): New function. * alloc.c (mark_char_table): Add extra argument to denote char table subtype. Adjust to match new layout of sub char-table. (mark_object): Always mark sub char-tables with mark_char_table. * chartab.c (make_sub_char_table, copy_sub_char_table) (sub_char_table_ref, sub_char_table_ref_and_range, sub_char_table_set) (sub_char_table_set_range, optimize_sub_char_table, map_sub_char_table) (map_sub_char_table_for_charset, uniprop_table_uncompress): All related users changed. * lread.c (read1): Adjust to match new layout of sub char-table.
Diffstat (limited to 'src/chartab.c')
-rw-r--r--src/chartab.c47
1 files changed, 17 insertions, 30 deletions
diff --git a/src/chartab.c b/src/chartab.c
index 4d4e6381b19..3906ad30b37 100644
--- a/src/chartab.c
+++ b/src/chartab.c
@@ -140,15 +140,11 @@ the char-table has no extra slot. */)
140static Lisp_Object 140static Lisp_Object
141make_sub_char_table (int depth, int min_char, Lisp_Object defalt) 141make_sub_char_table (int depth, int min_char, Lisp_Object defalt)
142{ 142{
143 Lisp_Object table; 143 int i;
144 int size = (PSEUDOVECSIZE (struct Lisp_Sub_Char_Table, contents) 144 Lisp_Object table = make_uninit_sub_char_table (depth, min_char);
145 + chartab_size[depth]);
146
147 table = Fmake_vector (make_number (size), defalt);
148 XSETPVECTYPE (XVECTOR (table), PVEC_SUB_CHAR_TABLE);
149 XSUB_CHAR_TABLE (table)->depth = make_number (depth);
150 XSUB_CHAR_TABLE (table)->min_char = make_number (min_char);
151 145
146 for (i = 0; i < chartab_size[depth]; i++)
147 XSUB_CHAR_TABLE (table)->contents[i] = defalt;
152 return table; 148 return table;
153} 149}
154 150
@@ -172,8 +168,8 @@ char_table_ascii (Lisp_Object table)
172static Lisp_Object 168static Lisp_Object
173copy_sub_char_table (Lisp_Object table) 169copy_sub_char_table (Lisp_Object table)
174{ 170{
175 int depth = XINT (XSUB_CHAR_TABLE (table)->depth); 171 int depth = XSUB_CHAR_TABLE (table)->depth;
176 int min_char = XINT (XSUB_CHAR_TABLE (table)->min_char); 172 int min_char = XSUB_CHAR_TABLE (table)->min_char;
177 Lisp_Object copy = make_sub_char_table (depth, min_char, Qnil); 173 Lisp_Object copy = make_sub_char_table (depth, min_char, Qnil);
178 int i; 174 int i;
179 175
@@ -220,10 +216,8 @@ static Lisp_Object
220sub_char_table_ref (Lisp_Object table, int c, bool is_uniprop) 216sub_char_table_ref (Lisp_Object table, int c, bool is_uniprop)
221{ 217{
222 struct Lisp_Sub_Char_Table *tbl = XSUB_CHAR_TABLE (table); 218 struct Lisp_Sub_Char_Table *tbl = XSUB_CHAR_TABLE (table);
223 int depth = XINT (tbl->depth);
224 int min_char = XINT (tbl->min_char);
225 Lisp_Object val; 219 Lisp_Object val;
226 int idx = CHARTAB_IDX (c, depth, min_char); 220 int idx = CHARTAB_IDX (c, tbl->depth, tbl->min_char);
227 221
228 val = tbl->contents[idx]; 222 val = tbl->contents[idx];
229 if (is_uniprop && UNIPROP_COMPRESSED_FORM_P (val)) 223 if (is_uniprop && UNIPROP_COMPRESSED_FORM_P (val))
@@ -265,8 +259,7 @@ sub_char_table_ref_and_range (Lisp_Object table, int c, int *from, int *to,
265 Lisp_Object defalt, bool is_uniprop) 259 Lisp_Object defalt, bool is_uniprop)
266{ 260{
267 struct Lisp_Sub_Char_Table *tbl = XSUB_CHAR_TABLE (table); 261 struct Lisp_Sub_Char_Table *tbl = XSUB_CHAR_TABLE (table);
268 int depth = XINT (tbl->depth); 262 int depth = tbl->depth, min_char = tbl->min_char;
269 int min_char = XINT (tbl->min_char);
270 int chartab_idx = CHARTAB_IDX (c, depth, min_char), idx; 263 int chartab_idx = CHARTAB_IDX (c, depth, min_char), idx;
271 Lisp_Object val; 264 Lisp_Object val;
272 265
@@ -402,8 +395,7 @@ static void
402sub_char_table_set (Lisp_Object table, int c, Lisp_Object val, bool is_uniprop) 395sub_char_table_set (Lisp_Object table, int c, Lisp_Object val, bool is_uniprop)
403{ 396{
404 struct Lisp_Sub_Char_Table *tbl = XSUB_CHAR_TABLE (table); 397 struct Lisp_Sub_Char_Table *tbl = XSUB_CHAR_TABLE (table);
405 int depth = XINT ((tbl)->depth); 398 int depth = tbl->depth, min_char = tbl->min_char;
406 int min_char = XINT ((tbl)->min_char);
407 int i = CHARTAB_IDX (c, depth, min_char); 399 int i = CHARTAB_IDX (c, depth, min_char);
408 Lisp_Object sub; 400 Lisp_Object sub;
409 401
@@ -458,8 +450,7 @@ sub_char_table_set_range (Lisp_Object table, int from, int to, Lisp_Object val,
458 bool is_uniprop) 450 bool is_uniprop)
459{ 451{
460 struct Lisp_Sub_Char_Table *tbl = XSUB_CHAR_TABLE (table); 452 struct Lisp_Sub_Char_Table *tbl = XSUB_CHAR_TABLE (table);
461 int depth = XINT ((tbl)->depth); 453 int depth = tbl->depth, min_char = tbl->min_char;
462 int min_char = XINT ((tbl)->min_char);
463 int chars_in_block = chartab_chars[depth]; 454 int chars_in_block = chartab_chars[depth];
464 int i, c, lim = chartab_size[depth]; 455 int i, c, lim = chartab_size[depth];
465 456
@@ -689,9 +680,8 @@ static Lisp_Object
689optimize_sub_char_table (Lisp_Object table, Lisp_Object test) 680optimize_sub_char_table (Lisp_Object table, Lisp_Object test)
690{ 681{
691 struct Lisp_Sub_Char_Table *tbl = XSUB_CHAR_TABLE (table); 682 struct Lisp_Sub_Char_Table *tbl = XSUB_CHAR_TABLE (table);
692 int depth = XINT (tbl->depth); 683 int i, depth = tbl->depth;
693 Lisp_Object elt, this; 684 Lisp_Object elt, this;
694 int i;
695 bool optimizable; 685 bool optimizable;
696 686
697 elt = XSUB_CHAR_TABLE (table)->contents[0]; 687 elt = XSUB_CHAR_TABLE (table)->contents[0];
@@ -778,8 +768,8 @@ map_sub_char_table (void (*c_function) (Lisp_Object, Lisp_Object, Lisp_Object),
778 { 768 {
779 struct Lisp_Sub_Char_Table *tbl = XSUB_CHAR_TABLE (table); 769 struct Lisp_Sub_Char_Table *tbl = XSUB_CHAR_TABLE (table);
780 770
781 depth = XINT (tbl->depth); 771 depth = tbl->depth;
782 min_char = XINT (tbl->min_char); 772 min_char = tbl->min_char;
783 max_char = min_char + chartab_chars[depth - 1] - 1; 773 max_char = min_char + chartab_chars[depth - 1] - 1;
784 } 774 }
785 else 775 else
@@ -973,12 +963,10 @@ map_sub_char_table_for_charset (void (*c_function) (Lisp_Object, Lisp_Object),
973 unsigned from, unsigned to) 963 unsigned from, unsigned to)
974{ 964{
975 struct Lisp_Sub_Char_Table *tbl = XSUB_CHAR_TABLE (table); 965 struct Lisp_Sub_Char_Table *tbl = XSUB_CHAR_TABLE (table);
976 int depth = XINT (tbl->depth); 966 int i, c = tbl->min_char, depth = tbl->depth;
977 int c, i;
978 967
979 if (depth < 3) 968 if (depth < 3)
980 for (i = 0, c = XINT (tbl->min_char); i < chartab_size[depth]; 969 for (i = 0; i < chartab_size[depth]; i++, c += chartab_chars[depth])
981 i++, c += chartab_chars[depth])
982 { 970 {
983 Lisp_Object this; 971 Lisp_Object this;
984 972
@@ -1000,7 +988,7 @@ map_sub_char_table_for_charset (void (*c_function) (Lisp_Object, Lisp_Object),
1000 } 988 }
1001 } 989 }
1002 else 990 else
1003 for (i = 0, c = XINT (tbl->min_char); i < chartab_size[depth]; i++, c ++) 991 for (i = 0; i < chartab_size[depth]; i++, c++)
1004 { 992 {
1005 Lisp_Object this; 993 Lisp_Object this;
1006 unsigned code; 994 unsigned code;
@@ -1147,8 +1135,7 @@ static Lisp_Object
1147uniprop_table_uncompress (Lisp_Object table, int idx) 1135uniprop_table_uncompress (Lisp_Object table, int idx)
1148{ 1136{
1149 Lisp_Object val = XSUB_CHAR_TABLE (table)->contents[idx]; 1137 Lisp_Object val = XSUB_CHAR_TABLE (table)->contents[idx];
1150 int min_char = (XINT (XSUB_CHAR_TABLE (table)->min_char) 1138 int min_char = XSUB_CHAR_TABLE (table)->min_char + chartab_chars[2] * idx;
1151 + chartab_chars[2] * idx);
1152 Lisp_Object sub = make_sub_char_table (3, min_char, Qnil); 1139 Lisp_Object sub = make_sub_char_table (3, min_char, Qnil);
1153 const unsigned char *p, *pend; 1140 const unsigned char *p, *pend;
1154 1141