diff options
| author | Paul Eggert | 2018-12-09 00:18:36 -0800 |
|---|---|---|
| committer | Paul Eggert | 2018-12-09 00:23:55 -0800 |
| commit | d79bb75683ceb4eee2f753eb38fa8db99aff4568 (patch) | |
| tree | b0b20c25387c2eb11b2c79e87898bec2c39b14ea /src/fontset.c | |
| parent | c2fdd50c3cb0b03d2414370c58c1aa2a6ec3311d (diff) | |
| download | emacs-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/fontset.c')
| -rw-r--r-- | src/fontset.c | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/src/fontset.c b/src/fontset.c index 1f877eb606a..07f42331170 100644 --- a/src/fontset.c +++ b/src/fontset.c | |||
| @@ -281,10 +281,10 @@ set_fontset_fallback (Lisp_Object fontset, Lisp_Object fallback) | |||
| 281 | ASET ((rfont_def), 3, make_fixnum (score)) | 281 | ASET ((rfont_def), 3, make_fixnum (score)) |
| 282 | #define RFONT_DEF_NEW(rfont_def, font_def) \ | 282 | #define RFONT_DEF_NEW(rfont_def, font_def) \ |
| 283 | do { \ | 283 | do { \ |
| 284 | (rfont_def) = Fmake_vector (make_fixnum (4), Qnil); \ | 284 | (rfont_def) = make_nil_vector (4); \ |
| 285 | ASET ((rfont_def), 1, (font_def)); \ | 285 | ASET (rfont_def, 1, font_def); \ |
| 286 | RFONT_DEF_SET_SCORE ((rfont_def), 0); \ | 286 | RFONT_DEF_SET_SCORE (rfont_def, 0); \ |
| 287 | } while (0) | 287 | } while (false) |
| 288 | 288 | ||
| 289 | 289 | ||
| 290 | /* Return the element of FONTSET for the character C. If FONTSET is a | 290 | /* Return the element of FONTSET for the character C. If FONTSET is a |
| @@ -327,11 +327,8 @@ fontset_ref (Lisp_Object fontset, int c) | |||
| 327 | #define FONTSET_ADD(fontset, range, elt, add) \ | 327 | #define FONTSET_ADD(fontset, range, elt, add) \ |
| 328 | (NILP (add) \ | 328 | (NILP (add) \ |
| 329 | ? (NILP (range) \ | 329 | ? (NILP (range) \ |
| 330 | ? (set_fontset_fallback \ | 330 | ? set_fontset_fallback (fontset, make_vector (1, elt)) \ |
| 331 | (fontset, Fmake_vector (make_fixnum (1), (elt)))) \ | 331 | : (void) Fset_char_table_range (fontset, range, make_vector (1, elt))) \ |
| 332 | : ((void) \ | ||
| 333 | Fset_char_table_range (fontset, range, \ | ||
| 334 | Fmake_vector (make_fixnum (1), elt)))) \ | ||
| 335 | : fontset_add ((fontset), (range), (elt), (add))) | 332 | : fontset_add ((fontset), (range), (elt), (add))) |
| 336 | 333 | ||
| 337 | static void | 334 | static void |
| @@ -340,7 +337,7 @@ fontset_add (Lisp_Object fontset, Lisp_Object range, Lisp_Object elt, Lisp_Objec | |||
| 340 | Lisp_Object args[2]; | 337 | Lisp_Object args[2]; |
| 341 | int idx = (EQ (add, Qappend) ? 0 : 1); | 338 | int idx = (EQ (add, Qappend) ? 0 : 1); |
| 342 | 339 | ||
| 343 | args[1 - idx] = Fmake_vector (make_fixnum (1), elt); | 340 | args[1 - idx] = make_vector (1, elt); |
| 344 | 341 | ||
| 345 | if (CONSP (range)) | 342 | if (CONSP (range)) |
| 346 | { | 343 | { |
| @@ -701,7 +698,6 @@ fontset_find_font (Lisp_Object fontset, int c, struct face *face, | |||
| 701 | { | 698 | { |
| 702 | /* We found a font. Open it and insert a new element for | 699 | /* We found a font. Open it and insert a new element for |
| 703 | that font in VEC. */ | 700 | that font in VEC. */ |
| 704 | Lisp_Object new_vec; | ||
| 705 | int j; | 701 | int j; |
| 706 | 702 | ||
| 707 | font_object = font_open_for_lface (f, font_entity, face->lface, | 703 | font_object = font_open_for_lface (f, font_entity, face->lface, |
| @@ -711,7 +707,7 @@ fontset_find_font (Lisp_Object fontset, int c, struct face *face, | |||
| 711 | RFONT_DEF_NEW (rfont_def, font_def); | 707 | RFONT_DEF_NEW (rfont_def, font_def); |
| 712 | RFONT_DEF_SET_OBJECT (rfont_def, font_object); | 708 | RFONT_DEF_SET_OBJECT (rfont_def, font_object); |
| 713 | RFONT_DEF_SET_SCORE (rfont_def, RFONT_DEF_SCORE (rfont_def)); | 709 | RFONT_DEF_SET_SCORE (rfont_def, RFONT_DEF_SCORE (rfont_def)); |
| 714 | new_vec = Fmake_vector (make_fixnum (ASIZE (vec) + 1), Qnil); | 710 | Lisp_Object new_vec = make_nil_vector (ASIZE (vec) + 1); |
| 715 | found_index++; | 711 | found_index++; |
| 716 | for (j = 0; j < found_index; j++) | 712 | for (j = 0; j < found_index; j++) |
| 717 | ASET (new_vec, j, AREF (vec, j)); | 713 | ASET (new_vec, j, AREF (vec, j)); |
| @@ -2062,9 +2058,7 @@ Lisp_Object dump_fontset (Lisp_Object) EXTERNALLY_VISIBLE; | |||
| 2062 | Lisp_Object | 2058 | Lisp_Object |
| 2063 | dump_fontset (Lisp_Object fontset) | 2059 | dump_fontset (Lisp_Object fontset) |
| 2064 | { | 2060 | { |
| 2065 | Lisp_Object vec; | 2061 | Lisp_Object vec = make_nil_vector (3); |
| 2066 | |||
| 2067 | vec = Fmake_vector (make_fixnum (3), Qnil); | ||
| 2068 | ASET (vec, 0, FONTSET_ID (fontset)); | 2062 | ASET (vec, 0, FONTSET_ID (fontset)); |
| 2069 | 2063 | ||
| 2070 | if (BASE_FONTSET_P (fontset)) | 2064 | if (BASE_FONTSET_P (fontset)) |
| @@ -2122,7 +2116,7 @@ syms_of_fontset (void) | |||
| 2122 | Vcached_fontset_data = Qnil; | 2116 | Vcached_fontset_data = Qnil; |
| 2123 | staticpro (&Vcached_fontset_data); | 2117 | staticpro (&Vcached_fontset_data); |
| 2124 | 2118 | ||
| 2125 | Vfontset_table = Fmake_vector (make_fixnum (32), Qnil); | 2119 | Vfontset_table = make_nil_vector (32); |
| 2126 | staticpro (&Vfontset_table); | 2120 | staticpro (&Vfontset_table); |
| 2127 | 2121 | ||
| 2128 | Vdefault_fontset = Fmake_char_table (Qfontset, Qnil); | 2122 | Vdefault_fontset = Fmake_char_table (Qfontset, Qnil); |