aboutsummaryrefslogtreecommitdiffstats
path: root/src/chartab.c
diff options
context:
space:
mode:
authorPaul Eggert2018-12-09 00:18:36 -0800
committerPaul Eggert2018-12-09 00:23:55 -0800
commitd79bb75683ceb4eee2f753eb38fa8db99aff4568 (patch)
treeb0b20c25387c2eb11b2c79e87898bec2c39b14ea /src/chartab.c
parentc2fdd50c3cb0b03d2414370c58c1aa2a6ec3311d (diff)
downloademacs-d79bb75683ceb4eee2f753eb38fa8db99aff4568.tar.gz
emacs-d79bb75683ceb4eee2f753eb38fa8db99aff4568.zip
Add make_vector and make_nil_vector
This makes the callers a bit easier to read, and doubtless improves efficiency very slightly. It also simplifies possible future changes to allow bignum indexes to buffers. * src/alloc.c (allocate_vectorlike): Prefer ptrdiff_t to size_t when either will do. (make_vector): New function. (Fmake_vector): Use it. * src/buffer.c (syms_of_buffer): * src/bytecode.c (syms_of_bytecode): * src/category.c (Fmake_category_table, init_category_once): * src/ccl.c (syms_of_ccl): * src/character.c (syms_of_character): * src/charset.c (Fdefine_charset_internal) (Ffind_charset_region, Ffind_charset_string): * src/chartab.c (copy_char_table): * src/coding.c (Fdefine_coding_system_internal, syms_of_coding): * src/composite.c (get_composition_id, Fcomposition_get_gstring): * src/composite.h (LGLYPH_NEW): * src/fns.c (concat, Flocale_info, make_hash_table): * src/font.c (font_otf_ValueRecord, font_otf_anchor) (build_style_table, syms_of_font): * src/fontset.c (RFONT_DEF_NEW, fontset_find_font) (dump_fontset, syms_of_fontset): * src/image.c (xpm_make_color_table_v): * src/keyboard.c (modify_event_symbol, menu_bar_items) (parse_menu_item, parse_tool_bar_item, init_tool_bar_items) (syms_of_keyboard): * src/keymap.c (Fdefine_key, describe_map, describe_vector): * src/lread.c (read_vector): * src/macfont.m (macfont_shape): * src/menu.c (init_menu_items): * src/nsfns.m (ns_make_monitor_attribute_list): * src/process.c (conv_sockaddr_to_lisp, network_interface_info): * src/profiler.c (make_log): * src/window.c (Fcurrent_window_configuration): * src/xdisp.c (with_echo_area_buffer_unwind_data) (format_mode_line_unwind_data): * src/xfaces.c (Finternal_make_lisp_face) (Fface_attributes_as_vector): * src/xfns.c (x_make_monitor_attribute_list) (Fx_display_monitor_attributes_list): * src/xfont.c (syms_of_xfont): * src/xselect.c (x_handle_dnd_message): * src/xwidget.c (save_script_callback): Prefer make_nil_vector (N) to Fmake_vector (make_fixnum (N), Qnil). * src/callint.c (Fcall_interactively): * src/charset.c (load_charset_map): * src/chartab.c (Fmake_char_table, uniprop_encode_value_numeric): * src/composite.c (get_composition_id) * src/dispnew.c (Fframe_or_buffer_changed_p) (syms_of_display): * src/fns.c (make_hash_table, maybe_resize_hash_table): * src/font.c (font_style_to_value): * src/fontset.c (FONTSET_ADD, fontset_add): * src/json.c (json_to_lisp): * src/keymap.c (syms_of_keymap): * src/lread.c (init_obarray): * src/profiler.c (make_log, Fprofiler_cpu_log): * src/term.c (term_get_fkeys_1): Prefer make_vector (N, V) to Fmake_vector (make_fixnum (N), V). * src/font.c (build_style_table): * src/macfont.m (macfont_shape): * src/process.c (conv_sockaddr_to_lisp, network_interface_info): Prefer make_uninit_vector if the vector will be initialized soon. * src/lisp.h (make_nil_vector): New function.
Diffstat (limited to 'src/chartab.c')
-rw-r--r--src/chartab.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/chartab.c b/src/chartab.c
index 3d38b3ce12e..16017f4a49a 100644
--- a/src/chartab.c
+++ b/src/chartab.c
@@ -125,7 +125,7 @@ the char-table has no extra slot. */)
125 } 125 }
126 126
127 size = CHAR_TABLE_STANDARD_SLOTS + n_extras; 127 size = CHAR_TABLE_STANDARD_SLOTS + n_extras;
128 vector = Fmake_vector (make_fixnum (size), init); 128 vector = make_vector (size, init);
129 XSETPVECTYPE (XVECTOR (vector), PVEC_CHAR_TABLE); 129 XSETPVECTYPE (XVECTOR (vector), PVEC_CHAR_TABLE);
130 set_char_table_parent (vector, Qnil); 130 set_char_table_parent (vector, Qnil);
131 set_char_table_purpose (vector, purpose); 131 set_char_table_purpose (vector, purpose);
@@ -184,16 +184,13 @@ copy_sub_char_table (Lisp_Object table)
184Lisp_Object 184Lisp_Object
185copy_char_table (Lisp_Object table) 185copy_char_table (Lisp_Object table)
186{ 186{
187 Lisp_Object copy;
188 int size = PVSIZE (table); 187 int size = PVSIZE (table);
189 int i; 188 Lisp_Object copy = make_nil_vector (size);
190
191 copy = Fmake_vector (make_fixnum (size), Qnil);
192 XSETPVECTYPE (XVECTOR (copy), PVEC_CHAR_TABLE); 189 XSETPVECTYPE (XVECTOR (copy), PVEC_CHAR_TABLE);
193 set_char_table_defalt (copy, XCHAR_TABLE (table)->defalt); 190 set_char_table_defalt (copy, XCHAR_TABLE (table)->defalt);
194 set_char_table_parent (copy, XCHAR_TABLE (table)->parent); 191 set_char_table_parent (copy, XCHAR_TABLE (table)->parent);
195 set_char_table_purpose (copy, XCHAR_TABLE (table)->purpose); 192 set_char_table_purpose (copy, XCHAR_TABLE (table)->purpose);
196 for (i = 0; i < chartab_size[0]; i++) 193 for (int i = 0; i < chartab_size[0]; i++)
197 set_char_table_contents 194 set_char_table_contents
198 (copy, i, 195 (copy, i,
199 (SUB_CHAR_TABLE_P (XCHAR_TABLE (table)->contents[i]) 196 (SUB_CHAR_TABLE_P (XCHAR_TABLE (table)->contents[i])
@@ -201,7 +198,7 @@ copy_char_table (Lisp_Object table)
201 : XCHAR_TABLE (table)->contents[i])); 198 : XCHAR_TABLE (table)->contents[i]));
202 set_char_table_ascii (copy, char_table_ascii (copy)); 199 set_char_table_ascii (copy, char_table_ascii (copy));
203 size -= CHAR_TABLE_STANDARD_SLOTS; 200 size -= CHAR_TABLE_STANDARD_SLOTS;
204 for (i = 0; i < size; i++) 201 for (int i = 0; i < size; i++)
205 set_char_table_extras (copy, i, XCHAR_TABLE (table)->extras[i]); 202 set_char_table_extras (copy, i, XCHAR_TABLE (table)->extras[i]);
206 203
207 XSETCHAR_TABLE (copy, XCHAR_TABLE (copy)); 204 XSETCHAR_TABLE (copy, XCHAR_TABLE (copy));
@@ -1249,7 +1246,7 @@ uniprop_encode_value_numeric (Lisp_Object table, Lisp_Object value)
1249 set_char_table_extras (table, 4, 1246 set_char_table_extras (table, 4,
1250 CALLN (Fvconcat, 1247 CALLN (Fvconcat,
1251 XCHAR_TABLE (table)->extras[4], 1248 XCHAR_TABLE (table)->extras[4],
1252 Fmake_vector (make_fixnum (1), value))); 1249 make_vector (1, value)));
1253 return make_fixnum (i); 1250 return make_fixnum (i);
1254} 1251}
1255 1252