aboutsummaryrefslogtreecommitdiffstats
path: root/src/composite.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/composite.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/composite.c')
-rw-r--r--src/composite.c31
1 files changed, 13 insertions, 18 deletions
diff --git a/src/composite.c b/src/composite.c
index 39c54fcfab3..9819805c399 100644
--- a/src/composite.c
+++ b/src/composite.c
@@ -216,7 +216,7 @@ get_composition_id (ptrdiff_t charpos, ptrdiff_t bytepos, ptrdiff_t nchars,
216 COMPONENTS (converted to a vector COMPONENTS-VEC) or, if it is 216 COMPONENTS (converted to a vector COMPONENTS-VEC) or, if it is
217 nil, vector of characters in the composition range. */ 217 nil, vector of characters in the composition range. */
218 if (FIXNUMP (components)) 218 if (FIXNUMP (components))
219 key = Fmake_vector (make_fixnum (1), components); 219 key = make_vector (1, components);
220 else if (STRINGP (components) || CONSP (components)) 220 else if (STRINGP (components) || CONSP (components))
221 key = Fvconcat (1, &components); 221 key = Fvconcat (1, &components);
222 else if (VECTORP (components)) 222 else if (VECTORP (components))
@@ -654,27 +654,22 @@ Lisp_Object
654composition_gstring_put_cache (Lisp_Object gstring, ptrdiff_t len) 654composition_gstring_put_cache (Lisp_Object gstring, ptrdiff_t len)
655{ 655{
656 struct Lisp_Hash_Table *h = XHASH_TABLE (gstring_hash_table); 656 struct Lisp_Hash_Table *h = XHASH_TABLE (gstring_hash_table);
657 EMACS_UINT hash; 657 Lisp_Object header = LGSTRING_HEADER (gstring);
658 Lisp_Object header, copy; 658 EMACS_UINT hash = h->test.hashfn (&h->test, header);
659 ptrdiff_t i;
660
661 header = LGSTRING_HEADER (gstring);
662 hash = h->test.hashfn (&h->test, header);
663 if (len < 0) 659 if (len < 0)
664 { 660 {
665 ptrdiff_t j, glyph_len = LGSTRING_GLYPH_LEN (gstring); 661 ptrdiff_t glyph_len = LGSTRING_GLYPH_LEN (gstring);
666 for (j = 0; j < glyph_len; j++) 662 for (len = 0; len < glyph_len; len++)
667 if (NILP (LGSTRING_GLYPH (gstring, j))) 663 if (NILP (LGSTRING_GLYPH (gstring, len)))
668 break; 664 break;
669 len = j;
670 } 665 }
671 666
672 copy = Fmake_vector (make_fixnum (len + 2), Qnil); 667 Lisp_Object copy = make_nil_vector (len + 2);
673 LGSTRING_SET_HEADER (copy, Fcopy_sequence (header)); 668 LGSTRING_SET_HEADER (copy, Fcopy_sequence (header));
674 for (i = 0; i < len; i++) 669 for (ptrdiff_t i = 0; i < len; i++)
675 LGSTRING_SET_GLYPH (copy, i, Fcopy_sequence (LGSTRING_GLYPH (gstring, i))); 670 LGSTRING_SET_GLYPH (copy, i, Fcopy_sequence (LGSTRING_GLYPH (gstring, i)));
676 i = hash_put (h, LGSTRING_HEADER (copy), copy, hash); 671 ptrdiff_t id = hash_put (h, LGSTRING_HEADER (copy), copy, hash);
677 LGSTRING_SET_ID (copy, make_fixnum (i)); 672 LGSTRING_SET_ID (copy, make_fixnum (id));
678 return copy; 673 return copy;
679} 674}
680 675
@@ -1759,7 +1754,7 @@ should be ignored. */)
1759 return gstring; 1754 return gstring;
1760 1755
1761 if (LGSTRING_GLYPH_LEN (gstring_work) < topos - frompos) 1756 if (LGSTRING_GLYPH_LEN (gstring_work) < topos - frompos)
1762 gstring_work = Fmake_vector (make_fixnum (topos - frompos + 2), Qnil); 1757 gstring_work = make_nil_vector (topos - frompos + 2);
1763 LGSTRING_SET_HEADER (gstring_work, header); 1758 LGSTRING_SET_HEADER (gstring_work, header);
1764 LGSTRING_SET_ID (gstring_work, Qnil); 1759 LGSTRING_SET_ID (gstring_work, Qnil);
1765 fill_gstring_body (gstring_work); 1760 fill_gstring_body (gstring_work);
@@ -1917,9 +1912,9 @@ syms_of_composite (void)
1917 staticpro (&gstring_work_headers); 1912 staticpro (&gstring_work_headers);
1918 gstring_work_headers = make_uninit_vector (8); 1913 gstring_work_headers = make_uninit_vector (8);
1919 for (i = 0; i < 8; i++) 1914 for (i = 0; i < 8; i++)
1920 ASET (gstring_work_headers, i, Fmake_vector (make_fixnum (i + 2), Qnil)); 1915 ASET (gstring_work_headers, i, make_nil_vector (i + 2));
1921 staticpro (&gstring_work); 1916 staticpro (&gstring_work);
1922 gstring_work = Fmake_vector (make_fixnum (10), Qnil); 1917 gstring_work = make_nil_vector (10);
1923 1918
1924 /* Text property `composition' should be nonsticky by default. */ 1919 /* Text property `composition' should be nonsticky by default. */
1925 Vtext_property_default_nonsticky 1920 Vtext_property_default_nonsticky