emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master d79bb75: Add make_vector and make_nil_vector


From: Paul Eggert
Subject: [Emacs-diffs] master d79bb75: Add make_vector and make_nil_vector
Date: Sun, 9 Dec 2018 03:24:00 -0500 (EST)

branch: master
commit d79bb75683ceb4eee2f753eb38fa8db99aff4568
Author: Paul Eggert <address@hidden>
Commit: Paul Eggert <address@hidden>

    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.
---
 src/alloc.c     | 14 ++++++++++---
 src/buffer.c    |  3 +--
 src/bytecode.c  | 10 +++------
 src/callint.c   |  2 +-
 src/category.c  |  5 ++---
 src/ccl.c       |  4 ++--
 src/character.c |  2 +-
 src/charset.c   | 16 ++++++--------
 src/chartab.c   | 13 +++++-------
 src/coding.c    | 65 ++++++++++++++++++++++++---------------------------------
 src/composite.c | 31 ++++++++++++---------------
 src/composite.h |  2 +-
 src/dispnew.c   |  4 ++--
 src/fns.c       | 20 ++++++++----------
 src/font.c      | 25 ++++++++++------------
 src/fontset.c   | 26 +++++++++--------------
 src/image.c     |  2 +-
 src/json.c      |  2 +-
 src/keyboard.c  | 32 +++++++++++-----------------
 src/keymap.c    | 20 ++++++++----------
 src/lisp.h      | 11 ++++++++++
 src/lread.c     | 28 ++++++++++---------------
 src/macfont.m   |  6 ++----
 src/menu.c      |  2 +-
 src/nsfns.m     |  2 +-
 src/process.c   | 47 +++++++++++++++++++----------------------
 src/profiler.c  |  5 ++---
 src/term.c      | 15 ++++++-------
 src/window.c    |  3 +--
 src/xdisp.c     |  4 ++--
 src/xfaces.c    | 10 +++------
 src/xfns.c      |  4 ++--
 src/xfont.c     |  2 +-
 src/xselect.c   |  2 +-
 src/xwidget.c   |  2 +-
 35 files changed, 195 insertions(+), 246 deletions(-)

diff --git a/src/alloc.c b/src/alloc.c
index 201e3f0..503ef98 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -3353,7 +3353,7 @@ static struct Lisp_Vector *
 allocate_vectorlike (ptrdiff_t len)
 {
   eassert (0 < len && len <= VECTOR_ELTS_MAX);
-  size_t nbytes = header_size + len * word_size;
+  ptrdiff_t nbytes = header_size + len * word_size;
   struct Lisp_Vector *p;
 
   MALLOC_BLOCK_INPUT;
@@ -3496,8 +3496,16 @@ See also the function `vector'.  */)
 {
   CHECK_TYPE (FIXNATP (length) && XFIXNAT (length) <= PTRDIFF_MAX,
              Qwholenump, length);
-  struct Lisp_Vector *p = allocate_vector (XFIXNAT (length));
-  for (ptrdiff_t i = 0; i < XFIXNAT (length); i++)
+  return make_vector (XFIXNAT (length), init);
+}
+
+/* Return a new vector of length LENGTH with each element being INIT.  */
+
+Lisp_Object
+make_vector (ptrdiff_t length, Lisp_Object init)
+{
+  struct Lisp_Vector *p = allocate_vector (length);
+  for (ptrdiff_t i = 0; i < length; i++)
     p->contents[i] = init;
   return make_lisp_ptr (p, Lisp_Vectorlike);
 }
diff --git a/src/buffer.c b/src/buffer.c
index 90ef886..a71bd77 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -5410,8 +5410,7 @@ void
 syms_of_buffer (void)
 {
   staticpro (&last_overlay_modification_hooks);
-  last_overlay_modification_hooks
-    = Fmake_vector (make_fixnum (10), Qnil);
+  last_overlay_modification_hooks = make_nil_vector (10);
 
   staticpro (&QSFundamental);
   staticpro (&Vbuffer_alist);
diff --git a/src/bytecode.c b/src/bytecode.c
index 40389e0..95f7b32 100644
--- a/src/bytecode.c
+++ b/src/bytecode.c
@@ -1494,13 +1494,9 @@ If a symbol has a property named `byte-code-meter' whose 
value is an
 integer, it is incremented each time that symbol's function is called.  */);
 
   byte_metering_on = false;
-  Vbyte_code_meter = Fmake_vector (make_fixnum (256), make_fixnum (0));
+  Vbyte_code_meter = make_nil_vector (256);
   DEFSYM (Qbyte_code_meter, "byte-code-meter");
-  {
-    int i = 256;
-    while (i--)
-      ASET (Vbyte_code_meter, i,
-           Fmake_vector (make_fixnum (256), make_fixnum (0)));
-  }
+  for (int i = 0; i < 256; i++)
+    ASET (Vbyte_code_meter, i, make_vector (256, make_fixnum (0)));
 #endif
 }
diff --git a/src/callint.c b/src/callint.c
index 81efb26..8741100 100644
--- a/src/callint.c
+++ b/src/callint.c
@@ -589,7 +589,7 @@ invoke it.  If KEYS is omitted or nil, the return value of
        case 'U':               /* Up event from last k or K.  */
          if (!NILP (up_event))
            {
-             args[i] = Fmake_vector (make_fixnum (1), up_event);
+             args[i] = make_vector (1, up_event);
              up_event = Qnil;
              visargs[i] = Fkey_description (args[i], Qnil);
            }
diff --git a/src/category.c b/src/category.c
index d6ccde5..c316e9a 100644
--- a/src/category.c
+++ b/src/category.c
@@ -271,8 +271,7 @@ DEFUN ("make-category-table", Fmake_category_table, 
Smake_category_table,
   set_char_table_defalt (val, MAKE_CATEGORY_SET);
   for (i = 0; i < (1 << CHARTAB_SIZE_BITS_0); i++)
     set_char_table_contents (val, i, MAKE_CATEGORY_SET);
-  Fset_char_table_extra_slot (val, make_fixnum (0),
-                             Fmake_vector (make_fixnum (95), Qnil));
+  Fset_char_table_extra_slot (val, make_fixnum (0), make_nil_vector (95));
   return val;
 }
 
@@ -446,7 +445,7 @@ init_category_once (void)
   /* Set a category set which contains nothing to the default.  */
   set_char_table_defalt (Vstandard_category_table, MAKE_CATEGORY_SET);
   Fset_char_table_extra_slot (Vstandard_category_table, make_fixnum (0),
-                             Fmake_vector (make_fixnum (95), Qnil));
+                             make_nil_vector (95));
 }
 
 void
diff --git a/src/ccl.c b/src/ccl.c
index 31d0a28..64e7045 100644
--- a/src/ccl.c
+++ b/src/ccl.c
@@ -2275,7 +2275,7 @@ void
 syms_of_ccl (void)
 {
   staticpro (&Vccl_program_table);
-  Vccl_program_table = Fmake_vector (make_fixnum (32), Qnil);
+  Vccl_program_table = make_nil_vector (32);
 
   DEFSYM (Qccl, "ccl");
   DEFSYM (Qcclp, "cclp");
@@ -2291,7 +2291,7 @@ syms_of_ccl (void)
 
   DEFVAR_LISP ("code-conversion-map-vector", Vcode_conversion_map_vector,
               doc: /* Vector of code conversion maps.  */);
-  Vcode_conversion_map_vector = Fmake_vector (make_fixnum (16), Qnil);
+  Vcode_conversion_map_vector = make_nil_vector (16);
 
   DEFVAR_LISP ("font-ccl-encoder-alist", Vfont_ccl_encoder_alist,
               doc: /* Alist of fontname patterns vs corresponding CCL program.
diff --git a/src/character.c b/src/character.c
index 0b14e47..63cb1fc 100644
--- a/src/character.c
+++ b/src/character.c
@@ -1124,7 +1124,7 @@ syms_of_character (void)
 Vector recording all translation tables ever defined.
 Each element is a pair (SYMBOL . TABLE) relating the table to the
 symbol naming it.  The ID of a translation table is an index into this vector. 
 */);
-  Vtranslation_table_vector = Fmake_vector (make_fixnum (16), Qnil);
+  Vtranslation_table_vector = make_nil_vector (16);
 
   DEFVAR_LISP ("auto-fill-chars", Vauto_fill_chars,
               doc: /*
diff --git a/src/charset.c b/src/charset.c
index c1a2378..83f4de7 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -261,7 +261,7 @@ load_charset_map (struct charset *charset, struct 
charset_map_entries *entries,
                {
                  int n = CODE_POINT_TO_INDEX (charset, max_code) + 1;
 
-                 vec = Fmake_vector (make_fixnum (n), make_fixnum (-1));
+                 vec = make_vector (n, make_fixnum (-1));
                  set_charset_attr (charset, charset_decoder, vec);
                }
              else
@@ -856,7 +856,7 @@ usage: (define-charset-internal ...)  */)
             Fcons (intern ("define-charset-internal"),
                    make_fixnum (nargs)));
 
-  attrs = Fmake_vector (make_fixnum (charset_attr_max), Qnil);
+  attrs = make_nil_vector (charset_attr_max);
 
   CHECK_SYMBOL (args[charset_arg_name]);
   ASET (attrs, charset_name, args[charset_arg_name]);
@@ -1563,7 +1563,7 @@ only `ascii', `eight-bit-control', and 
`eight-bit-graphic'.  */)
 
   from_byte = CHAR_TO_BYTE (from);
 
-  charsets = Fmake_vector (make_fixnum (charset_table_used), Qnil);
+  charsets = make_nil_vector (charset_table_used);
   while (1)
     {
       find_charsets_in_text (BYTE_POS_ADDR (from_byte), stop - from,
@@ -1594,18 +1594,14 @@ If STR is unibyte, the returned list may contain
 only `ascii', `eight-bit-control', and `eight-bit-graphic'. */)
   (Lisp_Object str, Lisp_Object table)
 {
-  Lisp_Object charsets;
-  int i;
-  Lisp_Object val;
-
   CHECK_STRING (str);
 
-  charsets = Fmake_vector (make_fixnum (charset_table_used), Qnil);
+  Lisp_Object charsets = make_nil_vector (charset_table_used);
   find_charsets_in_text (SDATA (str), SCHARS (str), SBYTES (str),
                         charsets, table,
                         STRING_MULTIBYTE (str));
-  val = Qnil;
-  for (i = charset_table_used - 1; i >= 0; i--)
+  Lisp_Object val = Qnil;
+  for (int i = charset_table_used - 1; i >= 0; i--)
     if (!NILP (AREF (charsets, i)))
       val = Fcons (CHARSET_NAME (charset_table + i), val);
   return val;
diff --git a/src/chartab.c b/src/chartab.c
index 3d38b3c..16017f4 100644
--- a/src/chartab.c
+++ b/src/chartab.c
@@ -125,7 +125,7 @@ the char-table has no extra slot.  */)
     }
 
   size = CHAR_TABLE_STANDARD_SLOTS + n_extras;
-  vector = Fmake_vector (make_fixnum (size), init);
+  vector = make_vector (size, init);
   XSETPVECTYPE (XVECTOR (vector), PVEC_CHAR_TABLE);
   set_char_table_parent (vector, Qnil);
   set_char_table_purpose (vector, purpose);
@@ -184,16 +184,13 @@ copy_sub_char_table (Lisp_Object table)
 Lisp_Object
 copy_char_table (Lisp_Object table)
 {
-  Lisp_Object copy;
   int size = PVSIZE (table);
-  int i;
-
-  copy = Fmake_vector (make_fixnum (size), Qnil);
+  Lisp_Object copy = make_nil_vector (size);
   XSETPVECTYPE (XVECTOR (copy), PVEC_CHAR_TABLE);
   set_char_table_defalt (copy, XCHAR_TABLE (table)->defalt);
   set_char_table_parent (copy, XCHAR_TABLE (table)->parent);
   set_char_table_purpose (copy, XCHAR_TABLE (table)->purpose);
-  for (i = 0; i < chartab_size[0]; i++)
+  for (int i = 0; i < chartab_size[0]; i++)
     set_char_table_contents
       (copy, i,
        (SUB_CHAR_TABLE_P (XCHAR_TABLE (table)->contents[i])
@@ -201,7 +198,7 @@ copy_char_table (Lisp_Object table)
        : XCHAR_TABLE (table)->contents[i]));
   set_char_table_ascii (copy, char_table_ascii (copy));
   size -= CHAR_TABLE_STANDARD_SLOTS;
-  for (i = 0; i < size; i++)
+  for (int i = 0; i < size; i++)
     set_char_table_extras (copy, i, XCHAR_TABLE (table)->extras[i]);
 
   XSETCHAR_TABLE (copy, XCHAR_TABLE (copy));
@@ -1249,7 +1246,7 @@ uniprop_encode_value_numeric (Lisp_Object table, 
Lisp_Object value)
     set_char_table_extras (table, 4,
                           CALLN (Fvconcat,
                                  XCHAR_TABLE (table)->extras[4],
-                                 Fmake_vector (make_fixnum (1), value)));
+                                 make_vector (1, value)));
   return make_fixnum (i);
 }
 
diff --git a/src/coding.c b/src/coding.c
index 0f715a2..398691f 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -10062,36 +10062,28 @@ DEFUN ("define-coding-system-internal", 
Fdefine_coding_system_internal,
 usage: (define-coding-system-internal ...)  */)
   (ptrdiff_t nargs, Lisp_Object *args)
 {
-  Lisp_Object name;
-  Lisp_Object spec_vec;                /* [ ATTRS ALIASE EOL_TYPE ] */
-  Lisp_Object attrs;           /* Vector of attributes.  */
-  Lisp_Object eol_type;
-  Lisp_Object aliases;
-  Lisp_Object coding_type, charset_list, safe_charsets;
   enum coding_category category;
-  Lisp_Object tail, val;
   int max_charset_id = 0;
-  int i;
 
   if (nargs < coding_arg_max)
     goto short_args;
 
-  attrs = Fmake_vector (make_fixnum (coding_attr_last_index), Qnil);
+  Lisp_Object attrs = make_nil_vector (coding_attr_last_index);
 
-  name = args[coding_arg_name];
+  Lisp_Object name = args[coding_arg_name];
   CHECK_SYMBOL (name);
   ASET (attrs, coding_attr_base_name, name);
 
-  val = args[coding_arg_mnemonic];
+  Lisp_Object val = args[coding_arg_mnemonic];
   if (! STRINGP (val))
     CHECK_CHARACTER (val);
   ASET (attrs, coding_attr_mnemonic, val);
 
-  coding_type = args[coding_arg_coding_type];
+  Lisp_Object coding_type = args[coding_arg_coding_type];
   CHECK_SYMBOL (coding_type);
   ASET (attrs, coding_attr_type, coding_type);
 
-  charset_list = args[coding_arg_charset_list];
+  Lisp_Object charset_list = args[coding_arg_charset_list];
   if (SYMBOLP (charset_list))
     {
       if (EQ (charset_list, Qiso_2022))
@@ -10106,7 +10098,7 @@ usage: (define-coding-system-internal ...)  */)
            error ("Invalid charset-list");
          charset_list = Vemacs_mule_charset_list;
        }
-      for (tail = charset_list; CONSP (tail); tail = XCDR (tail))
+      for (Lisp_Object tail = charset_list; CONSP (tail); tail = XCDR (tail))
        {
          if (! RANGED_FIXNUMP (0, XCAR (tail), INT_MAX - 1))
            error ("Invalid charset-list");
@@ -10117,7 +10109,7 @@ usage: (define-coding-system-internal ...)  */)
   else
     {
       charset_list = Fcopy_sequence (charset_list);
-      for (tail = charset_list; CONSP (tail); tail = XCDR (tail))
+      for (Lisp_Object tail = charset_list; CONSP (tail); tail = XCDR (tail))
        {
          struct charset *charset;
 
@@ -10138,9 +10130,9 @@ usage: (define-coding-system-internal ...)  */)
     }
   ASET (attrs, coding_attr_charset_list, charset_list);
 
-  safe_charsets = make_uninit_string (max_charset_id + 1);
+  Lisp_Object safe_charsets = make_uninit_string (max_charset_id + 1);
   memset (SDATA (safe_charsets), 255, max_charset_id + 1);
-  for (tail = charset_list; CONSP (tail); tail = XCDR (tail))
+  for (Lisp_Object tail = charset_list; CONSP (tail); tail = XCDR (tail))
     SSET (safe_charsets, XFIXNAT (XCAR (tail)), 0);
   ASET (attrs, coding_attr_safe_charsets, safe_charsets);
 
@@ -10194,9 +10186,9 @@ usage: (define-coding-system-internal ...)  */)
         If Nth element is a list of charset IDs, N is the first byte
         of one of them.  The list is sorted by dimensions of the
         charsets.  A charset of smaller dimension comes first. */
-      val = Fmake_vector (make_fixnum (256), Qnil);
+      val = make_nil_vector (256);
 
-      for (tail = charset_list; CONSP (tail); tail = XCDR (tail))
+      for (Lisp_Object tail = charset_list; CONSP (tail); tail = XCDR (tail))
        {
          struct charset *charset = CHARSET_FROM_ID (XFIXNAT (XCAR (tail)));
          int dim = CHARSET_DIMENSION (charset);
@@ -10205,7 +10197,7 @@ usage: (define-coding-system-internal ...)  */)
          if (CHARSET_ASCII_COMPATIBLE_P (charset))
            ASET (attrs, coding_attr_ascii_compat, Qt);
 
-         for (i = charset->code_space[idx];
+         for (int i = charset->code_space[idx];
               i <= charset->code_space[idx + 1]; i++)
            {
              Lisp_Object tmp, tmp2;
@@ -10265,7 +10257,7 @@ usage: (define-coding-system-internal ...)  */)
 
       val = args[coding_arg_ccl_valids];
       valids = Fmake_string (make_fixnum (256), make_fixnum (0), Qnil);
-      for (tail = val; CONSP (tail); tail = XCDR (tail))
+      for (Lisp_Object tail = val; CONSP (tail); tail = XCDR (tail))
        {
          int from, to;
 
@@ -10290,7 +10282,7 @@ usage: (define-coding-system-internal ...)  */)
                                     XCAR (val), make_fixnum (255));
              to = XFIXNUM (XCDR (val));
            }
-         for (i = from; i <= to; i++)
+         for (int i = from; i <= to; i++)
            SSET (valids, i, 1);
        }
       ASET (attrs, coding_attr_ccl_valids, valids);
@@ -10344,7 +10336,7 @@ usage: (define-coding-system-internal ...)  */)
 
       initial = Fcopy_sequence (args[coding_arg_iso2022_initial]);
       CHECK_VECTOR (initial);
-      for (i = 0; i < 4; i++)
+      for (int i = 0; i < 4; i++)
        {
          val = AREF (initial, i);
          if (! NILP (val))
@@ -10366,7 +10358,7 @@ usage: (define-coding-system-internal ...)  */)
       CHECK_FIXNUM_CDR (reg_usage);
 
       request = Fcopy_sequence (args[coding_arg_iso2022_request]);
-      for (tail = request; CONSP (tail); tail = XCDR (tail))
+      for (Lisp_Object tail = request; CONSP (tail); tail = XCDR (tail))
        {
          int id;
          Lisp_Object tmp1;
@@ -10377,13 +10369,14 @@ usage: (define-coding-system-internal ...)  */)
          CHECK_CHARSET_GET_ID (tmp1, id);
          CHECK_FIXNAT_CDR (val);
          if (XFIXNUM (XCDR (val)) >= 4)
-           error ("Invalid graphic register number: %"pI"d", XFIXNUM (XCDR 
(val)));
+           error ("Invalid graphic register number: %"pI"d",
+                  XFIXNUM (XCDR (val)));
          XSETCAR (val, make_fixnum (id));
        }
 
       flags = args[coding_arg_iso2022_flags];
       CHECK_FIXNAT (flags);
-      i = XFIXNUM (flags) & INT_MAX;
+      int i = XFIXNUM (flags) & INT_MAX;
       if (EQ (args[coding_arg_charset_list], Qiso_2022))
        i |= CODING_ISO_FLAG_FULL_SUPPORT;
       flags = make_fixnum (i);
@@ -10542,19 +10535,19 @@ usage: (define-coding-system-internal ...)  */)
               Fcons (CODING_ATTR_ASCII_COMPAT (attrs),
                      CODING_ATTR_PLIST (attrs))));
 
-  eol_type = args[coding_arg_eol_type];
+  Lisp_Object eol_type = args[coding_arg_eol_type];
   if (! NILP (eol_type)
       && ! EQ (eol_type, Qunix)
       && ! EQ (eol_type, Qdos)
       && ! EQ (eol_type, Qmac))
     error ("Invalid eol-type");
 
-  aliases = list1 (name);
+  Lisp_Object aliases = list1 (name);
 
   if (NILP (eol_type))
     {
       eol_type = make_subsidiaries (name);
-      for (i = 0; i < 3; i++)
+      for (int i = 0; i < 3; i++)
        {
          Lisp_Object this_spec, this_name, this_aliases, this_eol_type;
 
@@ -10575,7 +10568,7 @@ usage: (define-coding-system-internal ...)  */)
        }
     }
 
-  spec_vec = make_uninit_vector (3);
+  Lisp_Object spec_vec = make_uninit_vector (3);
   ASET (spec_vec, 0, attrs);
   ASET (spec_vec, 1, aliases);
   ASET (spec_vec, 2, eol_type);
@@ -10587,12 +10580,9 @@ usage: (define-coding-system-internal ...)  */)
     Vcoding_system_alist = Fcons (Fcons (Fsymbol_name (name), Qnil),
                                  Vcoding_system_alist);
 
-  {
-    int id = coding_categories[category].id;
-
-    if (id < 0 || EQ (name, CODING_ID_NAME (id)))
+  int id = coding_categories[category].id;
+  if (id < 0 || EQ (name, CODING_ID_NAME (id)))
       setup_coding_system (name, &coding_categories[category]);
-  }
 
   return Qnil;
 
@@ -10915,8 +10905,7 @@ syms_of_coding (void)
   DEFSYM (QCpre_write_conversion, ":pre-write-conversion");
   DEFSYM (QCascii_compatible_p, ":ascii-compatible-p");
 
-  Vcoding_category_table
-    = Fmake_vector (make_fixnum (coding_category_max), Qnil);
+  Vcoding_category_table = make_nil_vector (coding_category_max);
   staticpro (&Vcoding_category_table);
   /* Followings are target of code detection.  */
   ASET (Vcoding_category_table, coding_category_iso_7,
@@ -11220,7 +11209,7 @@ a coding system of ISO 2022 variant which has a flag
 `accept-latin-extra-code' t (e.g. iso-latin-1) on reading a file
 or reading output of a subprocess.
 Only 128th through 159th elements have a meaning.  */);
-  Vlatin_extra_code_table = Fmake_vector (make_fixnum (256), Qnil);
+  Vlatin_extra_code_table = make_nil_vector (256);
 
   DEFVAR_LISP ("select-safe-coding-system-function",
               Vselect_safe_coding_system_function,
diff --git a/src/composite.c b/src/composite.c
index 39c54fc..9819805 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,
      COMPONENTS (converted to a vector COMPONENTS-VEC) or, if it is
      nil, vector of characters in the composition range.  */
   if (FIXNUMP (components))
-    key = Fmake_vector (make_fixnum (1), components);
+    key = make_vector (1, components);
   else if (STRINGP (components) || CONSP (components))
     key = Fvconcat (1, &components);
   else if (VECTORP (components))
@@ -654,27 +654,22 @@ Lisp_Object
 composition_gstring_put_cache (Lisp_Object gstring, ptrdiff_t len)
 {
   struct Lisp_Hash_Table *h = XHASH_TABLE (gstring_hash_table);
-  EMACS_UINT hash;
-  Lisp_Object header, copy;
-  ptrdiff_t i;
-
-  header = LGSTRING_HEADER (gstring);
-  hash = h->test.hashfn (&h->test, header);
+  Lisp_Object header = LGSTRING_HEADER (gstring);
+  EMACS_UINT hash = h->test.hashfn (&h->test, header);
   if (len < 0)
     {
-      ptrdiff_t j, glyph_len = LGSTRING_GLYPH_LEN (gstring);
-      for (j = 0; j < glyph_len; j++)
-       if (NILP (LGSTRING_GLYPH (gstring, j)))
+      ptrdiff_t glyph_len = LGSTRING_GLYPH_LEN (gstring);
+      for (len = 0; len < glyph_len; len++)
+       if (NILP (LGSTRING_GLYPH (gstring, len)))
          break;
-      len = j;
     }
 
-  copy = Fmake_vector (make_fixnum (len + 2), Qnil);
+  Lisp_Object copy = make_nil_vector (len + 2);
   LGSTRING_SET_HEADER (copy, Fcopy_sequence (header));
-  for (i = 0; i < len; i++)
+  for (ptrdiff_t i = 0; i < len; i++)
     LGSTRING_SET_GLYPH (copy, i, Fcopy_sequence (LGSTRING_GLYPH (gstring, i)));
-  i = hash_put (h, LGSTRING_HEADER (copy), copy, hash);
-  LGSTRING_SET_ID (copy, make_fixnum (i));
+  ptrdiff_t id = hash_put (h, LGSTRING_HEADER (copy), copy, hash);
+  LGSTRING_SET_ID (copy, make_fixnum (id));
   return copy;
 }
 
@@ -1759,7 +1754,7 @@ should be ignored.  */)
     return gstring;
 
   if (LGSTRING_GLYPH_LEN (gstring_work) < topos - frompos)
-    gstring_work = Fmake_vector (make_fixnum (topos - frompos + 2), Qnil);
+    gstring_work = make_nil_vector (topos - frompos + 2);
   LGSTRING_SET_HEADER (gstring_work, header);
   LGSTRING_SET_ID (gstring_work, Qnil);
   fill_gstring_body (gstring_work);
@@ -1917,9 +1912,9 @@ syms_of_composite (void)
   staticpro (&gstring_work_headers);
   gstring_work_headers = make_uninit_vector (8);
   for (i = 0; i < 8; i++)
-    ASET (gstring_work_headers, i, Fmake_vector (make_fixnum (i + 2), Qnil));
+    ASET (gstring_work_headers, i, make_nil_vector (i + 2));
   staticpro (&gstring_work);
-  gstring_work = Fmake_vector (make_fixnum (10), Qnil);
+  gstring_work = make_nil_vector (10);
 
   /* Text property `composition' should be nonsticky by default.  */
   Vtext_property_default_nonsticky
diff --git a/src/composite.h b/src/composite.h
index 8039113..ad39a08 100644
--- a/src/composite.h
+++ b/src/composite.h
@@ -274,7 +274,7 @@ enum lglyph_indices
     LGLYPH_SIZE
   };
 
-#define LGLYPH_NEW() Fmake_vector (make_fixnum (LGLYPH_SIZE), Qnil)
+#define LGLYPH_NEW() make_nil_vector (LGLYPH_SIZE)
 #define LGLYPH_FROM(g) XFIXNUM (AREF ((g), LGLYPH_IX_FROM))
 #define LGLYPH_TO(g) XFIXNUM (AREF ((g), LGLYPH_IX_TO))
 #define LGLYPH_CHAR(g) XFIXNUM (AREF ((g), LGLYPH_IX_CHAR))
diff --git a/src/dispnew.c b/src/dispnew.c
index 8742d58..b628c69 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -5938,7 +5938,7 @@ pass nil for VARIABLE.  */)
       || n + 20 < ASIZE (state) / 2)
     /* Add 20 extra so we grow it less often.  */
     {
-      state = Fmake_vector (make_fixnum (n + 20), Qlambda);
+      state = make_vector (n + 20, Qlambda);
       if (! NILP (variable))
        Fset (variable, state);
       else
@@ -6236,7 +6236,7 @@ syms_of_display (void)
   defsubr (&Sdump_redisplay_history);
 #endif
 
-  frame_and_buffer_state = Fmake_vector (make_fixnum (20), Qlambda);
+  frame_and_buffer_state = make_vector (20, Qlambda);
   staticpro (&frame_and_buffer_state);
 
   /* This is the "purpose" slot of a display table.  */
diff --git a/src/fns.c b/src/fns.c
index c9a6dd6..9ef9601 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -732,7 +732,7 @@ concat (ptrdiff_t nargs, Lisp_Object *args,
   if (target_type == Lisp_Cons)
     val = Fmake_list (make_fixnum (result_len), Qnil);
   else if (target_type == Lisp_Vectorlike)
-    val = Fmake_vector (make_fixnum (result_len), Qnil);
+    val = make_nil_vector (result_len);
   else if (some_multibyte)
     val = make_uninit_multibyte_string (result_len, result_len_byte);
   else
@@ -3127,7 +3127,7 @@ The data read from the system are decoded using 
`locale-coding-system'.  */)
 #ifdef DAY_1
   else if (EQ (item, Qdays))   /* e.g. for calendar-day-name-array */
     {
-      Lisp_Object v = Fmake_vector (make_fixnum (7), Qnil);
+      Lisp_Object v = make_nil_vector (7);
       const int days[7] = {DAY_1, DAY_2, DAY_3, DAY_4, DAY_5, DAY_6, DAY_7};
       int i;
       synchronize_system_time_locale ();
@@ -3146,12 +3146,11 @@ The data read from the system are decoded using 
`locale-coding-system'.  */)
 #ifdef MON_1
   else if (EQ (item, Qmonths)) /* e.g. for calendar-month-name-array */
     {
-      Lisp_Object v = Fmake_vector (make_fixnum (12), Qnil);
+      Lisp_Object v = make_nil_vector (12);
       const int months[12] = {MON_1, MON_2, MON_3, MON_4, MON_5, MON_6, MON_7,
                              MON_8, MON_9, MON_10, MON_11, MON_12};
-      int i;
       synchronize_system_time_locale ();
-      for (i = 0; i < 12; i++)
+      for (int i = 0; i < 12; i++)
        {
          str = nl_langinfo (months[i]);
          AUTO_STRING (val, str);
@@ -3987,10 +3986,10 @@ make_hash_table (struct hash_table_test test, EMACS_INT 
size,
   h->rehash_threshold = rehash_threshold;
   h->rehash_size = rehash_size;
   h->count = 0;
-  h->key_and_value = Fmake_vector (make_fixnum (2 * size), Qnil);
-  h->hash = Fmake_vector (make_fixnum (size), Qnil);
-  h->next = Fmake_vector (make_fixnum (size), make_fixnum (-1));
-  h->index = Fmake_vector (make_fixnum (index_size), make_fixnum (-1));
+  h->key_and_value = make_nil_vector (2 * size);
+  h->hash = make_nil_vector (size);
+  h->next = make_vector (size, make_fixnum (-1));
+  h->index = make_vector (index_size, make_fixnum (-1));
   h->pure = pure;
 
   /* Set up the free list.  */
@@ -4085,8 +4084,7 @@ maybe_resize_hash_table (struct Lisp_Hash_Table *h)
       set_hash_key_and_value (h, larger_vector (h->key_and_value,
                                                2 * (new_size - old_size), -1));
       set_hash_hash (h, larger_vector (h->hash, new_size - old_size, -1));
-      set_hash_index (h, Fmake_vector (make_fixnum (index_size),
-                                      make_fixnum (-1)));
+      set_hash_index (h, make_vector (index_size, make_fixnum (-1)));
       set_hash_next (h, larger_vecalloc (h->next, new_size - old_size, -1));
 
       /* Update the free list.  Do it so that new entries are added at
diff --git a/src/font.c b/src/font.c
index 799d5db..e81c267 100644
--- a/src/font.c
+++ b/src/font.c
@@ -374,10 +374,10 @@ font_style_to_value (enum font_property_index prop, 
Lisp_Object val,
       if (! noerror)
        return -1;
       eassert (len < 255);
-      elt = Fmake_vector (make_fixnum (2), make_fixnum (100));
+      elt = make_vector (2, make_fixnum (100));
       ASET (elt, 1, val);
       ASET (font_style_table, prop - FONT_WEIGHT_INDEX,
-           CALLN (Fvconcat, table, Fmake_vector (make_fixnum (1), elt)));
+           CALLN (Fvconcat, table, make_vector (1, elt)));
       return (100 << 8) | (i << 4);
     }
   else
@@ -2035,7 +2035,7 @@ font_otf_DeviceTable (OTF_DeviceTable *device_table)
 Lisp_Object
 font_otf_ValueRecord (int value_format, OTF_ValueRecord *value_record)
 {
-  Lisp_Object val = Fmake_vector (make_fixnum (8), Qnil);
+  Lisp_Object val = make_nil_vector (8);
 
   if (value_format & OTF_XPlacement)
     ASET (val, 0, make_fixnum (value_record->XPlacement));
@@ -2059,9 +2059,7 @@ font_otf_ValueRecord (int value_format, OTF_ValueRecord 
*value_record)
 Lisp_Object
 font_otf_Anchor (OTF_Anchor *anchor)
 {
-  Lisp_Object val;
-
-  val = Fmake_vector (make_fixnum (anchor->AnchorFormat + 1), Qnil);
+  Lisp_Object val = make_nil_vector (anchor->AnchorFormat + 1);
   ASET (val, 0, make_fixnum (anchor->XCoordinate));
   ASET (val, 1, make_fixnum (anchor->YCoordinate));
   if (anchor->AnchorFormat == 2)
@@ -5170,14 +5168,13 @@ If the named font is not yet loaded, return nil.  */)
 static Lisp_Object
 build_style_table (const struct table_entry *entry, int nelement)
 {
-  int i, j;
-  Lisp_Object table, elt;
-
-  table = make_uninit_vector (nelement);
-  for (i = 0; i < nelement; i++)
+  Lisp_Object table = make_uninit_vector (nelement);
+  for (int i = 0; i < nelement; i++)
     {
-      for (j = 0; entry[i].names[j]; j++);
-      elt = Fmake_vector (make_fixnum (j + 1), Qnil);
+      int j;
+      for (j = 0; entry[i].names[j]; j++)
+       continue;
+      Lisp_Object elt = make_nil_vector (j + 1);
       ASET (elt, 0, make_fixnum (entry[i].numeric));
       for (j = 0; entry[i].names[j]; j++)
        ASET (elt, j + 1, intern_c_string (entry[i].names[j]));
@@ -5359,7 +5356,7 @@ syms_of_font (void)
   scratch_font_prefer = Ffont_spec (0, NULL);
 
   staticpro (&Vfont_log_deferred);
-  Vfont_log_deferred = Fmake_vector (make_fixnum (3), Qnil);
+  Vfont_log_deferred = make_nil_vector (3);
 
 #if 0
 #ifdef HAVE_LIBOTF
diff --git a/src/fontset.c b/src/fontset.c
index 1f877eb..07f4233 100644
--- a/src/fontset.c
+++ b/src/fontset.c
@@ -281,10 +281,10 @@ set_fontset_fallback (Lisp_Object fontset, Lisp_Object 
fallback)
   ASET ((rfont_def), 3, make_fixnum (score))
 #define RFONT_DEF_NEW(rfont_def, font_def)             \
   do {                                                 \
-    (rfont_def) = Fmake_vector (make_fixnum (4), Qnil);        \
-    ASET ((rfont_def), 1, (font_def));                 \
-    RFONT_DEF_SET_SCORE ((rfont_def), 0);              \
-  } while (0)
+    (rfont_def) = make_nil_vector (4);                 \
+    ASET (rfont_def, 1, font_def);                     \
+    RFONT_DEF_SET_SCORE (rfont_def, 0);                        \
+  } while (false)
 
 
 /* Return the element of FONTSET for the character C.  If FONTSET is a
@@ -327,11 +327,8 @@ fontset_ref (Lisp_Object fontset, int c)
 #define FONTSET_ADD(fontset, range, elt, add)                          \
   (NILP (add)                                                          \
    ? (NILP (range)                                                     \
-      ? (set_fontset_fallback                                          \
-        (fontset, Fmake_vector (make_fixnum (1), (elt))))              \
-      : ((void)                                                                
\
-        Fset_char_table_range (fontset, range,                         \
-                               Fmake_vector (make_fixnum (1), elt))))  \
+      ? set_fontset_fallback (fontset, make_vector (1, elt))           \
+      : (void) Fset_char_table_range (fontset, range, make_vector (1, elt))) \
    : fontset_add ((fontset), (range), (elt), (add)))
 
 static void
@@ -340,7 +337,7 @@ fontset_add (Lisp_Object fontset, Lisp_Object range, 
Lisp_Object elt, Lisp_Objec
   Lisp_Object args[2];
   int idx = (EQ (add, Qappend) ? 0 : 1);
 
-  args[1 - idx] = Fmake_vector (make_fixnum (1), elt);
+  args[1 - idx] = make_vector (1, elt);
 
   if (CONSP (range))
     {
@@ -701,7 +698,6 @@ fontset_find_font (Lisp_Object fontset, int c, struct face 
*face,
        {
          /* We found a font.  Open it and insert a new element for
             that font in VEC.  */
-         Lisp_Object new_vec;
          int j;
 
          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,
          RFONT_DEF_NEW (rfont_def, font_def);
          RFONT_DEF_SET_OBJECT (rfont_def, font_object);
          RFONT_DEF_SET_SCORE (rfont_def, RFONT_DEF_SCORE (rfont_def));
-         new_vec = Fmake_vector (make_fixnum (ASIZE (vec) + 1), Qnil);
+         Lisp_Object new_vec = make_nil_vector (ASIZE (vec) + 1);
          found_index++;
          for (j = 0; j < found_index; j++)
            ASET (new_vec, j, AREF (vec, j));
@@ -2062,9 +2058,7 @@ Lisp_Object dump_fontset (Lisp_Object) EXTERNALLY_VISIBLE;
 Lisp_Object
 dump_fontset (Lisp_Object fontset)
 {
-  Lisp_Object vec;
-
-  vec = Fmake_vector (make_fixnum (3), Qnil);
+  Lisp_Object vec = make_nil_vector (3);
   ASET (vec, 0, FONTSET_ID (fontset));
 
   if (BASE_FONTSET_P (fontset))
@@ -2122,7 +2116,7 @@ syms_of_fontset (void)
   Vcached_fontset_data = Qnil;
   staticpro (&Vcached_fontset_data);
 
-  Vfontset_table = Fmake_vector (make_fixnum (32), Qnil);
+  Vfontset_table = make_nil_vector (32);
   staticpro (&Vfontset_table);
 
   Vdefault_fontset = Fmake_char_table (Qfontset, Qnil);
diff --git a/src/image.c b/src/image.c
index 633d66e..b54cd76 100644
--- a/src/image.c
+++ b/src/image.c
@@ -4028,7 +4028,7 @@ xpm_make_color_table_v (void (**put_func) (Lisp_Object, 
const char *, int,
 {
   *put_func = xpm_put_color_table_v;
   *get_func = xpm_get_color_table_v;
-  return Fmake_vector (make_fixnum (256), Qnil);
+  return make_nil_vector (256);
 }
 
 static void
diff --git a/src/json.c b/src/json.c
index e5c0dc2..770b63c 100644
--- a/src/json.c
+++ b/src/json.c
@@ -817,7 +817,7 @@ json_to_lisp (json_t *json, struct json_configuration *conf)
         size_t size = json_array_size (json);
         if (FIXNUM_OVERFLOW_P (size))
           overflow_error ();
-        Lisp_Object result = Fmake_vector (make_fixed_natnum (size), Qunbound);
+        Lisp_Object result = make_vector (size, Qunbound);
         for (ptrdiff_t i = 0; i < size; ++i)
           ASET (result, i,
                 json_to_lisp (json_array_get (json, i), conf));
diff --git a/src/keyboard.c b/src/keyboard.c
index 59acb2d..baf2f51 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -6448,12 +6448,7 @@ modify_event_symbol (ptrdiff_t symbol_num, int 
modifiers, Lisp_Object symbol_kin
     {
       if (! VECTORP (*symbol_table)
          || ASIZE (*symbol_table) != table_size)
-       {
-         Lisp_Object size;
-
-         XSETFASTINT (size, table_size);
-         *symbol_table = Fmake_vector (size, Qnil);
-       }
+       *symbol_table = make_nil_vector (table_size);
 
       value = AREF (*symbol_table, symbol_num);
     }
@@ -7362,7 +7357,7 @@ menu_bar_items (Lisp_Object old)
   if (!NILP (old))
     menu_bar_items_vector = old;
   else
-    menu_bar_items_vector = Fmake_vector (make_fixnum (24), Qnil);
+    menu_bar_items_vector = make_nil_vector (24);
   menu_bar_items_index = 0;
 
   /* Build our list of keymaps.
@@ -7605,8 +7600,7 @@ parse_menu_item (Lisp_Object item, int inmenubar)
 
   /* Create item_properties vector if necessary.  */
   if (NILP (item_properties))
-    item_properties
-      = Fmake_vector (make_fixnum (ITEM_PROPERTY_ENABLE + 1), Qnil);
+    item_properties = make_nil_vector (ITEM_PROPERTY_ENABLE + 1);
 
   /* Initialize optional entries.  */
   for (i = ITEM_PROPERTY_DEF; i < ITEM_PROPERTY_ENABLE; i++)
@@ -8100,8 +8094,7 @@ parse_tool_bar_item (Lisp_Object key, Lisp_Object item)
        set_prop (i, Qnil);
     }
   else
-    tool_bar_item_properties
-      = Fmake_vector (make_fixnum (TOOL_BAR_ITEM_NSLOTS), Qnil);
+    tool_bar_item_properties = make_nil_vector (TOOL_BAR_ITEM_NSLOTS);
 
   /* Set defaults.  */
   set_prop (TOOL_BAR_ITEM_KEY, key);
@@ -8296,7 +8289,7 @@ init_tool_bar_items (Lisp_Object reuse)
   if (VECTORP (reuse))
     tool_bar_items_vector = reuse;
   else
-    tool_bar_items_vector = Fmake_vector (make_fixnum (64), Qnil);
+    tool_bar_items_vector = make_nil_vector (64);
   ntool_bar_items = 0;
 }
 
@@ -11184,32 +11177,31 @@ syms_of_keyboard (void)
       }
   }
 
-  button_down_location = Fmake_vector (make_fixnum (5), Qnil);
+  button_down_location = make_nil_vector (5);
   staticpro (&button_down_location);
-  mouse_syms = Fmake_vector (make_fixnum (5), Qnil);
+  mouse_syms = make_nil_vector (5);
   staticpro (&mouse_syms);
-  wheel_syms = Fmake_vector (make_fixnum (ARRAYELTS (lispy_wheel_names)),
-                            Qnil);
+  wheel_syms = make_nil_vector (ARRAYELTS (lispy_wheel_names));
   staticpro (&wheel_syms);
 
   {
     int i;
     int len = ARRAYELTS (modifier_names);
 
-    modifier_symbols = Fmake_vector (make_fixnum (len), Qnil);
+    modifier_symbols = make_nil_vector (len);
     for (i = 0; i < len; i++)
       if (modifier_names[i])
        ASET (modifier_symbols, i, intern_c_string (modifier_names[i]));
     staticpro (&modifier_symbols);
   }
 
-  recent_keys = Fmake_vector (make_fixnum (NUM_RECENT_KEYS), Qnil);
+  recent_keys = make_nil_vector (NUM_RECENT_KEYS);
   staticpro (&recent_keys);
 
-  this_command_keys = Fmake_vector (make_fixnum (40), Qnil);
+  this_command_keys = make_nil_vector (40);
   staticpro (&this_command_keys);
 
-  raw_keybuf = Fmake_vector (make_fixnum (30), Qnil);
+  raw_keybuf = make_nil_vector (30);
   staticpro (&raw_keybuf);
 
   DEFSYM (Qcommand_execute, "command-execute");
diff --git a/src/keymap.c b/src/keymap.c
index 3a79bf4..a1c9eb6 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -1093,7 +1093,7 @@ binding KEY to DEF is added at the front of KEYMAP.  */)
 
   if (VECTORP (def) && ASIZE (def) > 0 && CONSP (AREF (def, 0)))
     { /* DEF is apparently an XEmacs-style keyboard macro.  */
-      Lisp_Object tmp = Fmake_vector (make_fixnum (ASIZE (def)), Qnil);
+      Lisp_Object tmp = make_nil_vector (ASIZE (def));
       ptrdiff_t i = ASIZE (def);
       while (--i >= 0)
        {
@@ -1931,14 +1931,12 @@ then the value includes only maps for prefixes that 
start with PREFIX.  */)
             we don't have to deal with the possibility of a string.  */
          if (STRINGP (prefix))
            {
-             int i, i_byte, c;
-             Lisp_Object copy;
-
-             copy = Fmake_vector (make_fixnum (SCHARS (prefix)), Qnil);
-             for (i = 0, i_byte = 0; i < SCHARS (prefix);)
+             ptrdiff_t i_byte = 0;
+             Lisp_Object copy = make_nil_vector (SCHARS (prefix));
+             for (ptrdiff_t i = 0; i < SCHARS (prefix); )
                {
-                 int i_before = i;
-
+                 ptrdiff_t i_before = i;
+                 int c;
                  FETCH_STRING_CHAR_ADVANCE (c, prefix, i, i_byte);
                  if (SINGLE_BYTE_CHAR_P (c) && (c & 0200))
                    c ^= 0200 | meta_modifier;
@@ -3141,7 +3139,7 @@ describe_map (Lisp_Object map, Lisp_Object prefix,
   /* This vector gets used to present single keys to Flookup_key.  Since
      that is done once per keymap element, we don't want to cons up a
      fresh vector every time.  */
-  kludge = Fmake_vector (make_fixnum (1), Qnil);
+  kludge = make_nil_vector (1);
   definition = Qnil;
 
   map = call1 (Qkeymap_canonicalize, map);
@@ -3390,7 +3388,7 @@ describe_vector (Lisp_Object vector, Lisp_Object prefix, 
Lisp_Object args,
   /* This vector gets used to present single keys to Flookup_key.  Since
      that is done once per vector element, we don't want to cons up a
      fresh vector every time.  */
-  kludge = Fmake_vector (make_fixnum (1), Qnil);
+  kludge = make_nil_vector (1);
 
   if (partial)
     suppress = intern ("suppress-keymap");
@@ -3690,7 +3688,7 @@ be preferred.  */);
   DEFSYM (Qremap, "remap");
   DEFSYM (QCadvertised_binding, ":advertised-binding");
 
-  command_remapping_vector = Fmake_vector (make_fixnum (2), Qremap);
+  command_remapping_vector = make_vector (2, Qremap);
   staticpro (&command_remapping_vector);
 
   where_is_cache_keymaps = Qt;
diff --git a/src/lisp.h b/src/lisp.h
index 77b8b63..3943bf6 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -3694,6 +3694,7 @@ build_string (const char *str)
 }
 
 extern Lisp_Object pure_cons (Lisp_Object, Lisp_Object);
+extern Lisp_Object make_vector (ptrdiff_t, Lisp_Object);
 extern void make_byte_code (struct Lisp_Vector *);
 extern struct Lisp_Vector *allocate_vector (ptrdiff_t);
 
@@ -3726,6 +3727,16 @@ make_uninit_sub_char_table (int depth, int min_char)
   return v;
 }
 
+/* Make a vector of SIZE nils.  */
+
+INLINE Lisp_Object
+make_nil_vector (ptrdiff_t size)
+{
+  Lisp_Object vec = make_uninit_vector (size);
+  memclear (XVECTOR (vec)->contents, size * word_size);
+  return vec;
+}
+
 extern struct Lisp_Vector *allocate_pseudovector (int, int, int,
                                                  enum pvec_type);
 
diff --git a/src/lread.c b/src/lread.c
index 5f38714..4c6b767 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -3846,23 +3846,17 @@ string_to_number (char const *string, int base, 
ptrdiff_t *plen)
 static Lisp_Object
 read_vector (Lisp_Object readcharfun, bool bytecodeflag)
 {
-  ptrdiff_t i, size;
-  Lisp_Object *ptr;
-  Lisp_Object tem, item, vector;
-  struct Lisp_Cons *otem;
-  Lisp_Object len;
-
-  tem = read_list (1, readcharfun);
-  len = Flength (tem);
-  if (bytecodeflag && XFIXNAT (len) <= COMPILED_STACK_DEPTH)
+  Lisp_Object tem = read_list (1, readcharfun);
+  Lisp_Object len = Flength (tem);
+  ptrdiff_t size = XFIXNAT (len);
+  if (bytecodeflag && size <= COMPILED_STACK_DEPTH)
     error ("Invalid byte code");
-  vector = Fmake_vector (len, Qnil);
+  Lisp_Object vector = make_nil_vector (size);
 
-  size = XFIXNAT (len);
-  ptr = XVECTOR (vector)->contents;
-  for (i = 0; i < size; i++)
+  Lisp_Object *ptr = XVECTOR (vector)->contents;
+  for (ptrdiff_t i = 0; i < size; i++)
     {
-      item = Fcar (tem);
+      Lisp_Object item = Fcar (tem);
       /* If `load-force-doc-strings' is t when reading a lazily-loaded
         bytecode object, the docstring containing the bytecode and
         constants values must be treated as unibyte and passed to
@@ -3896,7 +3890,7 @@ read_vector (Lisp_Object readcharfun, bool bytecodeflag)
                  if (!CONSP (item))
                    error ("Invalid byte code");
 
-                 otem = XCONS (item);
+                 struct Lisp_Cons *otem = XCONS (item);
                  bytestr = XCAR (item);
                  item = XCDR (item);
                  free_cons (otem);
@@ -3916,7 +3910,7 @@ read_vector (Lisp_Object readcharfun, bool bytecodeflag)
            }
        }
       ASET (vector, i, item);
-      otem = XCONS (tem);
+      struct Lisp_Cons *otem = XCONS (tem);
       tem = Fcdr (tem);
       free_cons (otem);
     }
@@ -4383,7 +4377,7 @@ OBARRAY defaults to the value of `obarray'.  */)
 void
 init_obarray (void)
 {
-  Vobarray = Fmake_vector (make_fixnum (OBARRAY_SIZE), make_fixnum (0));
+  Vobarray = make_vector (OBARRAY_SIZE, make_fixnum (0));
   initial_obarray = Vobarray;
   staticpro (&initial_obarray);
 
diff --git a/src/macfont.m b/src/macfont.m
index c9a1eda..d137648 100644
--- a/src/macfont.m
+++ b/src/macfont.m
@@ -2992,7 +2992,7 @@ macfont_shape (Lisp_Object lgstring)
 
       if (NILP (lglyph))
         {
-          lglyph = Fmake_vector (make_fixnum (LGLYPH_SIZE), Qnil);
+          lglyph = make_nil_vector (LGLYPH_SIZE);
           LGSTRING_SET_GLYPH (lgstring, i, lglyph);
         }
 
@@ -3044,9 +3044,7 @@ macfont_shape (Lisp_Object lgstring)
       wadjust = lround (gl->advance);
       if (xoff != 0 || yoff != 0 || wadjust != metrics.width)
         {
-          Lisp_Object vec;
-
-          vec = Fmake_vector (make_fixnum (3), Qnil);
+          Lisp_Object vec = make_uninit_vector (3);
           ASET (vec, 0, make_fixnum (xoff));
           ASET (vec, 1, make_fixnum (yoff));
           ASET (vec, 2, make_fixnum (wadjust));
diff --git a/src/menu.c b/src/menu.c
index d75a842..53272f9 100644
--- a/src/menu.c
+++ b/src/menu.c
@@ -86,7 +86,7 @@ init_menu_items (void)
   if (NILP (menu_items))
     {
       menu_items_allocated = 60;
-      menu_items = Fmake_vector (make_fixnum (menu_items_allocated), Qnil);
+      menu_items = make_nil_vector (menu_items_allocated);
     }
 
   menu_items_inuse = Qt;
diff --git a/src/nsfns.m b/src/nsfns.m
index 659bce8..0ca9743 100644
--- a/src/nsfns.m
+++ b/src/nsfns.m
@@ -2476,7 +2476,7 @@ ns_make_monitor_attribute_list (struct MonitorInfo 
*monitors,
                                 int primary_monitor,
                                 const char *source)
 {
-  Lisp_Object monitor_frames = Fmake_vector (make_fixnum (n_monitors), Qnil);
+  Lisp_Object monitor_frames = make_nil_vector (n_monitors);
   Lisp_Object frame, rest;
   NSArray *screens = [NSScreen screens];
   int i;
diff --git a/src/process.c b/src/process.c
index 7e78e17..8e0b234 100644
--- a/src/process.c
+++ b/src/process.c
@@ -2492,7 +2492,6 @@ Lisp_Object
 conv_sockaddr_to_lisp (struct sockaddr *sa, ptrdiff_t len)
 {
   Lisp_Object address;
-  ptrdiff_t i;
   unsigned char *cp;
   struct Lisp_Vector *p;
 
@@ -2508,7 +2507,7 @@ conv_sockaddr_to_lisp (struct sockaddr *sa, ptrdiff_t len)
       {
        DECLARE_POINTER_ALIAS (sin, struct sockaddr_in, sa);
        len = sizeof (sin->sin_addr) + 1;
-       address = Fmake_vector (make_fixnum (len), Qnil);
+       address = make_uninit_vector (len);
        p = XVECTOR (address);
        p->contents[--len] = make_fixnum (ntohs (sin->sin_port));
        cp = (unsigned char *) &sin->sin_addr;
@@ -2520,10 +2519,10 @@ conv_sockaddr_to_lisp (struct sockaddr *sa, ptrdiff_t 
len)
        DECLARE_POINTER_ALIAS (sin6, struct sockaddr_in6, sa);
        DECLARE_POINTER_ALIAS (ip6, uint16_t, &sin6->sin6_addr);
        len = sizeof (sin6->sin6_addr) / 2 + 1;
-       address = Fmake_vector (make_fixnum (len), Qnil);
+       address = make_uninit_vector (len);
        p = XVECTOR (address);
        p->contents[--len] = make_fixnum (ntohs (sin6->sin6_port));
-       for (i = 0; i < len; i++)
+       for (ptrdiff_t i = 0; i < len; i++)
          p->contents[i] = make_fixnum (ntohs (ip6[i]));
        return address;
       }
@@ -2552,16 +2551,14 @@ conv_sockaddr_to_lisp (struct sockaddr *sa, ptrdiff_t 
len)
 #endif
     default:
       len -= offsetof (struct sockaddr, sa_family) + sizeof (sa->sa_family);
-      address = Fcons (make_fixnum (sa->sa_family),
-                      Fmake_vector (make_fixnum (len), Qnil));
+      address = Fcons (make_fixnum (sa->sa_family), make_nil_vector (len));
       p = XVECTOR (XCDR (address));
       cp = (unsigned char *) &sa->sa_family + sizeof (sa->sa_family);
       break;
     }
 
-  i = 0;
-  while (i < len)
-    p->contents[i++] = make_fixnum (*cp++);
+  for (ptrdiff_t i = 0; i < len; i++)
+    p->contents[i] = make_fixnum (*cp++);
 
   return address;
 }
@@ -4363,7 +4360,7 @@ network_interface_info (Lisp_Object ifname)
   Lisp_Object res = Qnil;
   Lisp_Object elt;
   int s;
-  bool any = 0;
+  bool any = false;
   ptrdiff_t count;
 #if (! (defined SIOCGIFHWADDR && defined HAVE_STRUCT_IFREQ_IFR_HWADDR) \
      && defined HAVE_GETIFADDRS && defined LLADDR)
@@ -4396,7 +4393,7 @@ network_interface_info (Lisp_Object ifname)
       if (flags < 0 && sizeof (rq.ifr_flags) < sizeof (flags))
         flags = (unsigned short) rq.ifr_flags;
 
-      any = 1;
+      any = true;
       for (fp = ifflag_table; flags != 0 && fp->flag_sym; fp++)
        {
          if (flags & fp->flag_bit)
@@ -4420,12 +4417,11 @@ network_interface_info (Lisp_Object ifname)
 #if defined (SIOCGIFHWADDR) && defined (HAVE_STRUCT_IFREQ_IFR_HWADDR)
   if (ioctl (s, SIOCGIFHWADDR, &rq) == 0)
     {
-      Lisp_Object hwaddr = Fmake_vector (make_fixnum (6), Qnil);
-      register struct Lisp_Vector *p = XVECTOR (hwaddr);
-      int n;
+      Lisp_Object hwaddr = make_uninit_vector (6);
+      struct Lisp_Vector *p = XVECTOR (hwaddr);
 
-      any = 1;
-      for (n = 0; n < 6; n++)
+      any = true;
+      for (int n = 0; n < 6; n++)
        p->contents[n] = make_fixnum (((unsigned char *)
                                       &rq.ifr_hwaddr.sa_data[0])
                                      [n]);
@@ -4434,11 +4430,10 @@ network_interface_info (Lisp_Object ifname)
 #elif defined (HAVE_GETIFADDRS) && defined (LLADDR)
   if (getifaddrs (&ifap) != -1)
     {
-      Lisp_Object hwaddr = Fmake_vector (make_fixnum (6), Qnil);
-      register struct Lisp_Vector *p = XVECTOR (hwaddr);
-      struct ifaddrs *it;
+      Lisp_Object hwaddr = make_nil_vector (6);
+      struct Lisp_Vector *p = XVECTOR (hwaddr);
 
-      for (it = ifap; it != NULL; it = it->ifa_next)
+      for (struct ifaddrs *it = ifap; it != NULL; it = it->ifa_next)
         {
          DECLARE_POINTER_ALIAS (sdl, struct sockaddr_dl, it->ifa_addr);
           unsigned char linkaddr[6];
@@ -4466,10 +4461,12 @@ network_interface_info (Lisp_Object ifname)
   res = Fcons (elt, res);
 
   elt = Qnil;
-#if defined (SIOCGIFNETMASK) && (defined (HAVE_STRUCT_IFREQ_IFR_NETMASK) || 
defined (HAVE_STRUCT_IFREQ_IFR_ADDR))
+#if (defined SIOCGIFNETMASK \
+     && (defined HAVE_STRUCT_IFREQ_IFR_NETMASK \
+        || defined HAVE_STRUCT_IFREQ_IFR_ADDR))
   if (ioctl (s, SIOCGIFNETMASK, &rq) == 0)
     {
-      any = 1;
+      any = true;
 #ifdef HAVE_STRUCT_IFREQ_IFR_NETMASK
       elt = conv_sockaddr_to_lisp (&rq.ifr_netmask, sizeof (rq.ifr_netmask));
 #else
@@ -4483,8 +4480,8 @@ network_interface_info (Lisp_Object ifname)
 #if defined (SIOCGIFBRDADDR) && defined (HAVE_STRUCT_IFREQ_IFR_BROADADDR)
   if (ioctl (s, SIOCGIFBRDADDR, &rq) == 0)
     {
-      any = 1;
-      elt = conv_sockaddr_to_lisp (&rq.ifr_broadaddr, sizeof 
(rq.ifr_broadaddr));
+      any = true;
+      elt = conv_sockaddr_to_lisp (&rq.ifr_broadaddr, sizeof rq.ifr_broadaddr);
     }
 #endif
   res = Fcons (elt, res);
@@ -4493,7 +4490,7 @@ network_interface_info (Lisp_Object ifname)
 #if defined (SIOCGIFADDR) && defined (HAVE_STRUCT_IFREQ_IFR_ADDR)
   if (ioctl (s, SIOCGIFADDR, &rq) == 0)
     {
-      any = 1;
+      any = true;
       elt = conv_sockaddr_to_lisp (&rq.ifr_addr, sizeof (rq.ifr_addr));
     }
 #endif
diff --git a/src/profiler.c b/src/profiler.c
index 7330f88..6d97107 100644
--- a/src/profiler.c
+++ b/src/profiler.c
@@ -54,8 +54,7 @@ make_log (EMACS_INT heap_size, EMACS_INT max_stack_depth)
      with the vectors we'll put in them.  */
   ptrdiff_t i = ASIZE (h->key_and_value) >> 1;
   while (i > 0)
-    set_hash_key_slot (h, --i,
-                      Fmake_vector (make_fixnum (max_stack_depth), Qnil));
+    set_hash_key_slot (h, --i, make_nil_vector (max_stack_depth));
   return log;
 }
 
@@ -422,7 +421,7 @@ Before returning, a new log is allocated for future 
samples.  */)
   cpu_log = (profiler_cpu_running
             ? make_log (profiler_log_size, profiler_max_stack_depth)
             : Qnil);
-  Fputhash (Fmake_vector (make_fixnum (1), QAutomatic_GC),
+  Fputhash (make_vector (1, QAutomatic_GC),
            make_fixnum (cpu_gc_count),
            result);
   cpu_gc_count = 0;
diff --git a/src/term.c b/src/term.c
index 852dc23..3465908 100644
--- a/src/term.c
+++ b/src/term.c
@@ -1359,8 +1359,7 @@ term_get_fkeys_1 (void)
       char *sequence = tgetstr (keys[i].cap, address);
       if (sequence)
        Fdefine_key (KVAR (kboard, Vinput_decode_map), build_string (sequence),
-                    Fmake_vector (make_fixnum (1),
-                                  intern (keys[i].name)));
+                    make_vector (1, intern (keys[i].name)));
     }
 
   /* The uses of the "k0" capability are inconsistent; sometimes it
@@ -1379,13 +1378,13 @@ term_get_fkeys_1 (void)
          /* Define f0 first, so that f10 takes precedence in case the
             key sequences happens to be the same.  */
          Fdefine_key (KVAR (kboard, Vinput_decode_map), build_string (k0),
-                      Fmake_vector (make_fixnum (1), intern ("f0")));
+                      make_vector (1, intern ("f0")));
        Fdefine_key (KVAR (kboard, Vinput_decode_map), build_string (k_semi),
-                    Fmake_vector (make_fixnum (1), intern ("f10")));
+                    make_vector (1, intern ("f10")));
       }
     else if (k0)
       Fdefine_key (KVAR (kboard, Vinput_decode_map), build_string (k0),
-                  Fmake_vector (make_fixnum (1), intern (k0_name)));
+                  make_vector (1, intern (k0_name)));
   }
 
   /* Set up cookies for numbered function keys above f10. */
@@ -1408,8 +1407,7 @@ term_get_fkeys_1 (void)
            {
              sprintf (fkey, "f%d", i);
              Fdefine_key (KVAR (kboard, Vinput_decode_map), build_string 
(sequence),
-                          Fmake_vector (make_fixnum (1),
-                                        intern (fkey)));
+                          make_vector (1, intern (fkey)));
            }
        }
       }
@@ -1425,8 +1423,7 @@ term_get_fkeys_1 (void)
          char *sequence = tgetstr (cap2, address);                     \
          if (sequence)                                                 \
            Fdefine_key (KVAR (kboard, Vinput_decode_map), build_string 
(sequence), \
-                        Fmake_vector (make_fixnum (1),                 \
-                                      intern (sym)));                  \
+                        make_vector (1, intern (sym)));                \
        }
 
       /* if there's no key_next keycap, map key_npage to `next' keysym */
diff --git a/src/window.c b/src/window.c
index 31e9782..9da77ff 100644
--- a/src/window.c
+++ b/src/window.c
@@ -7044,8 +7044,7 @@ saved by this function.  */)
   tem = make_uninit_vector (n_windows);
   data->saved_windows = tem;
   for (i = 0; i < n_windows; i++)
-    ASET (tem, i,
-         Fmake_vector (make_fixnum (VECSIZE (struct saved_window)), Qnil));
+    ASET (tem, i, make_nil_vector (VECSIZE (struct saved_window)));
   save_window_save (FRAME_ROOT_WINDOW (f), XVECTOR (tem), 0);
   XSETWINDOW_CONFIGURATION (tem, data);
   return (tem);
diff --git a/src/xdisp.c b/src/xdisp.c
index 9a0752f..4d9990c 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -10977,7 +10977,7 @@ with_echo_area_buffer_unwind_data (struct window *w)
   Vwith_echo_area_save_vector = Qnil;
 
   if (NILP (vector))
-    vector = Fmake_vector (make_fixnum (11), Qnil);
+    vector = make_nil_vector (11);
 
   XSETBUFFER (tmp, current_buffer); ASET (vector, i, tmp); ++i;
   ASET (vector, i, Vdeactivate_mark); ++i;
@@ -11850,7 +11850,7 @@ format_mode_line_unwind_data (struct frame 
*target_frame,
   Vmode_line_unwind_vector = Qnil;
 
   if (NILP (vector))
-    vector = Fmake_vector (make_fixnum (10), Qnil);
+    vector = make_nil_vector (10);
 
   ASET (vector, 0, make_fixnum (mode_line_target));
   ASET (vector, 1, make_fixnum (MODE_LINE_NOPROP_LEN (0)));
diff --git a/src/xfaces.c b/src/xfaces.c
index 76b23a3..11feaec 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -2615,8 +2615,7 @@ Value is a vector of face attributes.  */)
   /* Add a global definition if there is none.  */
   if (NILP (global_lface))
     {
-      global_lface = Fmake_vector (make_fixnum (LFACE_VECTOR_SIZE),
-                                  Qunspecified);
+      global_lface = make_vector (LFACE_VECTOR_SIZE, Qunspecified);
       ASET (global_lface, 0, Qface);
       Vface_new_frame_defaults = Fcons (Fcons (face, global_lface),
                                        Vface_new_frame_defaults);
@@ -2643,8 +2642,7 @@ Value is a vector of face attributes.  */)
     {
       if (NILP (lface))
        {
-         lface = Fmake_vector (make_fixnum (LFACE_VECTOR_SIZE),
-                               Qunspecified);
+         lface = make_vector (LFACE_VECTOR_SIZE, Qunspecified);
          ASET (lface, 0, Qface);
          fset_face_alist (f, Fcons (Fcons (face, lface), f->face_alist));
        }
@@ -4775,9 +4773,7 @@ DEFUN ("face-attributes-as-vector", 
Fface_attributes_as_vector,
        doc: /* Return a vector of face attributes corresponding to PLIST.  */)
   (Lisp_Object plist)
 {
-  Lisp_Object lface;
-  lface = Fmake_vector (make_fixnum (LFACE_VECTOR_SIZE),
-                       Qunspecified);
+  Lisp_Object lface = make_vector (LFACE_VECTOR_SIZE, Qunspecified);
   merge_face_ref (NULL, XFRAME (selected_frame),
                   plist, XVECTOR (lface)->contents,
                  true, 0);
diff --git a/src/xfns.c b/src/xfns.c
index c4cf59d..de177bf 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -4628,7 +4628,7 @@ x_make_monitor_attribute_list (struct MonitorInfo 
*monitors,
                                struct x_display_info *dpyinfo,
                                const char *source)
 {
-  Lisp_Object monitor_frames = Fmake_vector (make_fixnum (n_monitors), Qnil);
+  Lisp_Object monitor_frames = make_nil_vector (n_monitors);
   Lisp_Object frame, rest;
 
   FOR_EACH_FRAME (rest, frame)
@@ -4931,7 +4931,7 @@ Internal use only, use `display-monitor-attributes-list' 
instead.  */)
 #endif
   n_monitors = gdk_screen_get_n_monitors (gscreen);
 #endif
-  monitor_frames = Fmake_vector (make_fixnum (n_monitors), Qnil);
+  monitor_frames = make_nil_vector (n_monitors);
   monitors = xzalloc (n_monitors * sizeof *monitors);
 
   FOR_EACH_FRAME (rest, frame)
diff --git a/src/xfont.c b/src/xfont.c
index 73caa70..02976f6 100644
--- a/src/xfont.c
+++ b/src/xfont.c
@@ -1101,6 +1101,6 @@ syms_of_xfont (void)
   staticpro (&xfont_scripts_cache);
   xfont_scripts_cache = CALLN (Fmake_hash_table, QCtest, Qequal);
   staticpro (&xfont_scratch_props);
-  xfont_scratch_props = Fmake_vector (make_fixnum (8), Qnil);
+  xfont_scratch_props = make_nil_vector (8);
   register_font_driver (&xfont_driver, NULL);
 }
diff --git a/src/xselect.c b/src/xselect.c
index a87784f..e1f353b 100644
--- a/src/xselect.c
+++ b/src/xselect.c
@@ -2474,7 +2474,7 @@ x_handle_dnd_message (struct frame *f, const 
XClientMessageEvent *event,
       data = (unsigned char *) idata;
     }
 
-  vec = Fmake_vector (make_fixnum (4), Qnil);
+  vec = make_nil_vector (4);
   ASET (vec, 0, SYMBOL_NAME (x_atom_to_symbol (FRAME_DISPLAY_INFO (f),
                                               event->message_type)));
   ASET (vec, 1, frame);
diff --git a/src/xwidget.c b/src/xwidget.c
index 791dad4..9229a82 100644
--- a/src/xwidget.c
+++ b/src/xwidget.c
@@ -733,7 +733,7 @@ save_script_callback (struct xwidget *xw, Lisp_Object 
script, Lisp_Object fun)
 {
   Lisp_Object cbs = xw->script_callbacks;
   if (NILP (cbs))
-    xw->script_callbacks = cbs = Fmake_vector (make_fixnum (32), Qnil);
+    xw->script_callbacks = cbs = make_nil_vector (32);
 
   /* Find first free index.  */
   ptrdiff_t idx;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]