changeset 74163:f7736a8bd079

Use AREF/ASIZE macros. (concat): Provide the full ANSI prototype.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Fri, 24 Nov 2006 18:42:14 +0000
parents 378d4ce7b0ca
children a3d2bf407246
files src/ChangeLog src/fns.c
diffstat 2 files changed, 49 insertions(+), 53 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Fri Nov 24 16:48:32 2006 +0000
+++ b/src/ChangeLog	Fri Nov 24 18:42:14 2006 +0000
@@ -1,3 +1,8 @@
+2006-11-24  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* fns.c: Use AREF/ASIZE macros.
+	(concat): Provide the full ANSI prototype.
+
 2006-11-24  Juanma Barranquero  <lekktu@gmail.com>
 
 	* buffer.c (syms_of_buffer) <buffer-undo-list>: Doc fix.
@@ -42,15 +47,13 @@
 
 2006-11-19  Andreas Schwab  <schwab@gnu.org>
 
-	* xfaces.c (Fdisplay_supports_face_attributes_p): Initialize
-	supports.
+	* xfaces.c (Fdisplay_supports_face_attributes_p): Initialize supports.
 
 	* xmenu.c (Fx_popup_menu): Initialize selection.
 
 2006-11-18  Andreas Schwab  <schwab@suse.de>
 
-	* s/gnu-linux.h (GC_MARK_SECONDARY_STACK): Update call to
-	mark_memory.
+	* s/gnu-linux.h (GC_MARK_SECONDARY_STACK): Update call to mark_memory.
 
 2006-11-17  Tetsurou Okazaki  <okazaki@be.to>  (tiny change)
 
@@ -68,8 +71,7 @@
 
 2006-11-14  Kenichi Handa  <handa@m17n.org>
 
-	* coding.c (code_convert_region): Initialize
-	coding->heading_ascii.
+	* coding.c (code_convert_region): Initialize coding->heading_ascii.
 	(decode_coding_string, code_convert_region): Likewise.
 
 2006-11-14  YAMAMOTO Mitsuharu  <mituharu@math.s.chiba-u.ac.jp>
@@ -166,7 +168,7 @@
 
 2006-11-05  Mark Davies  <mark@mcs.vuw.ac.nz>  (tiny change)
 
-	* s/netbsd.h (POSIX_SIGNALS): Defined.
+	* s/netbsd.h (POSIX_SIGNALS): Define.
 
 2006-11-05  Martin Rudalics  <rudalics@gmx.at>
 
@@ -199,8 +201,8 @@
 	(unexec_regions_merge): Don't merge if null pages of preceding region
 	is not too small.  Use long format in printf.
 	(copy_segment, copy_data_segment): Show filesize.
-	(copy_data_segment): Write filesize bytes of region data.  Adjust
-	filesize in segment command accordingly.
+	(copy_data_segment): Write filesize bytes of region data.
+	Adjust filesize in segment command accordingly.
 	(dump_it): Use long format in printf.
 
 2006-11-05  Juanma Barranquero  <lekktu@gmail.com>
@@ -299,8 +301,8 @@
 	`swap_nibbles' static const.
 	(atsu_get_text_layout_with_text_ptr): Make variables `lengths',
 	`tags', `sizes', `values' static const.
-	(mac_draw_string_common): Make variables `context' static.  Make
-	variables `tags', `sizes', and `values' static const.
+	(mac_draw_string_common): Make variables `context' static.
+	Make variables `tags', `sizes', and `values' static const.
 	(pcm_get_status, x_detect_focus_change, x_scroll_bar_handle_click)
 	(xlfdpat_create, xlfdpat_block_match_1, xlfdpat_match)
 	(mac_to_x_fontname, parse_x_font_name, add_mac_font_name)
@@ -311,8 +313,8 @@
 	(fn_keycode_to_keycode_table): Make static const.
 	(mac_load_query_font): Make variables `tags', `sizes', `values',
 	`types', and `selectors' static const.
-	(mac_handle_command_event, mac_handle_window_event): Make
-	variables `names' and `types' static const.
+	(mac_handle_command_event, mac_handle_window_event):
+	Make variables `names' and `types' static const.
 	(init_command_handler, install_window_handler): Make variables
 	`specs*' static const.
 	(mac_handle_font_event, mac_handle_text_input_event)
@@ -404,7 +406,7 @@
 2006-10-16  Jan Dj,Ad(Brv  <jan.h.d@swipnet.se>
 
 	* gtkutil.c (get_utf8_string): Remove warnings with casts.
-	(xg_tool_bar_button_cb): Ditto
+	(xg_tool_bar_button_cb): Ditto.
 	(xg_tool_bar_callback): Ditto.
 
 2006-10-16  YAMAMOTO Mitsuharu  <mituharu@math.s.chiba-u.ac.jp>
--- a/src/fns.c	Fri Nov 24 16:48:32 2006 +0000
+++ b/src/fns.c	Fri Nov 24 18:42:14 2006 +0000
@@ -150,7 +150,7 @@
   if (STRINGP (sequence))
     XSETFASTINT (val, SCHARS (sequence));
   else if (VECTORP (sequence))
-    XSETFASTINT (val, XVECTOR (sequence)->size);
+    XSETFASTINT (val, ASIZE (sequence));
   else if (SUB_CHAR_TABLE_P (sequence))
     XSETFASTINT (val, SUB_CHAR_TABLE_ORDINARY_SLOTS);
   else if (CHAR_TABLE_P (sequence))
@@ -158,7 +158,7 @@
   else if (BOOL_VECTOR_P (sequence))
     XSETFASTINT (val, XBOOL_VECTOR (sequence)->size);
   else if (COMPILEDP (sequence))
-    XSETFASTINT (val, XVECTOR (sequence)->size & PSEUDOVECTOR_SIZE_MASK);
+    XSETFASTINT (val, ASIZE (sequence) & PSEUDOVECTOR_SIZE_MASK);
   else if (CONSP (sequence))
     {
       i = 0;
@@ -391,9 +391,9 @@
 /* "gcc -O3" enables automatic function inlining, which optimizes out
    the arguments for the invocations of this function, whereas it
    expects these values on the stack.  */
-static Lisp_Object concat () __attribute__((noinline));
+static Lisp_Object concat P_ ((int nargs, Lisp_Object *args, enum Lisp_Type target_type, int last_special)) __attribute__((noinline));
 #else  /* !__GNUC__ */
-static Lisp_Object concat ();
+static Lisp_Object concat P_ ((int nargs, Lisp_Object *args, enum Lisp_Type target_type, int last_special));
 #endif
 
 /* ARGSUSED */
@@ -617,7 +617,7 @@
 	  if (VECTORP (this))
 	    for (i = 0; i < len; i++)
 	      {
-		ch = XVECTOR (this)->contents[i];
+		ch = AREF (this, i);
 		CHECK_NUMBER (ch);
 		this_len_byte = CHAR_BYTES (XINT (ch));
 		result_len_byte += this_len_byte;
@@ -770,7 +770,7 @@
 		thisindex++;
 	      }
 	    else
-	      elt = XVECTOR (this)->contents[thisindex++];
+	      elt = AREF (this, thisindex++);
 
 	    /* Store this element into the result.  */
 	    if (toindex < 0)
@@ -780,7 +780,7 @@
 		tail = XCDR (tail);
 	      }
 	    else if (VECTORP (val))
-	      XVECTOR (val)->contents[toindex++] = elt;
+	      AREF (val, toindex++) = elt;
 	    else
 	      {
 		CHECK_NUMBER (elt);
@@ -1261,7 +1261,7 @@
       size_byte = SBYTES (string);
     }
   else
-    size = XVECTOR (string)->size;
+    size = ASIZE (string);
 
   if (NILP (to))
     {
@@ -1299,8 +1299,7 @@
 			    string, make_number (0), res, Qnil);
     }
   else
-    res = Fvector (to_char - from_char,
-		   XVECTOR (string)->contents + from_char);
+    res = Fvector (to_char - from_char, &AREF (string, from_char));
 
   return res;
 }
@@ -1384,7 +1383,7 @@
       size_byte = SBYTES (string);
     }
   else
-    size = XVECTOR (string)->size;
+    size = ASIZE (string);
 
   if (!(0 <= from && from <= to && to <= size))
     args_out_of_range_3 (string, make_number (from), make_number (to));
@@ -1398,8 +1397,7 @@
 			    string, make_number (0), res, Qnil);
     }
   else
-    res = Fvector (to - from,
-		   XVECTOR (string)->contents + from);
+    res = Fvector (to - from, AREF (string, from));
 
   return res;
 }
@@ -2245,11 +2243,11 @@
     case Lisp_Vectorlike:
       {
 	register int i;
-	EMACS_INT size = XVECTOR (o1)->size;
+	EMACS_INT size = ASIZE (o1);
 	/* Pseudovectors have the type encoded in the size field, so this test
 	   actually checks that the objects have the same type as well as the
 	   same size.  */
-	if (XVECTOR (o2)->size != size)
+	if (ASIZE (o2) != size)
 	  return 0;
 	/* Boolvectors are compared much like strings.  */
 	if (BOOL_VECTOR_P (o1))
@@ -2279,8 +2277,8 @@
 	for (i = 0; i < size; i++)
 	  {
 	    Lisp_Object v1, v2;
-	    v1 = XVECTOR (o1)->contents [i];
-	    v2 = XVECTOR (o2)->contents [i];
+	    v1 = AREF (o1, i);
+	    v2 = AREF (o2, i);
 	    if (!internal_equal (v1, v2, depth + 1, props))
 	      return 0;
 	  }
@@ -2321,7 +2319,7 @@
   if (VECTORP (array))
     {
       register Lisp_Object *p = XVECTOR (array)->contents;
-      size = XVECTOR (array)->size;
+      size = ASIZE (array);
       for (index = 0; index < size; index++)
 	p[index] = item;
     }
@@ -2549,7 +2547,7 @@
 
       charset_info = Fget (range, Qcharset);
       CHECK_VECTOR (charset_info);
-      charset_id = XINT (XVECTOR (charset_info)->contents[0]);
+      charset_id = XINT (AREF (charset_info, 0));
       ch = Fmake_char_internal (make_number (charset_id),
 				make_number (0), make_number (0));
     }
@@ -2675,7 +2673,7 @@
     Faset (char_table, range, value);
   else if (VECTORP (range))
     {
-      int size = XVECTOR (range)->size;
+      int size = ASIZE (range);
       Lisp_Object *val = XVECTOR (range)->contents;
       Lisp_Object ch = Fmake_char_internal (size <= 0 ? Qnil : val[0],
 					    size <= 1 ? Qnil : val[1],
@@ -3061,14 +3059,14 @@
   else
     GCPRO2 (fn, seq);
   /* We need not explicitly protect `tail' because it is used only on lists, and
-    1) lists are not relocated and 2) the list is marked via `seq' so will not be freed */
+    1) lists are not relocated and 2) the list is marked via `seq' so will not
+    be freed */
 
   if (VECTORP (seq))
     {
       for (i = 0; i < leni; i++)
 	{
-	  dummy = XVECTOR (seq)->contents[i];
-	  dummy = call1 (fn, dummy);
+	  dummy = call1 (fn, AREF (seq, i));
 	  if (vals)
 	    vals[i] = dummy;
 	}
@@ -3079,11 +3077,7 @@
 	{
 	  int byte;
 	  byte = XBOOL_VECTOR (seq)->data[i / BOOL_VECTOR_BITS_PER_CHAR];
-	  if (byte & (1 << (i % BOOL_VECTOR_BITS_PER_CHAR)))
-	    dummy = Qt;
-	  else
-	    dummy = Qnil;
-
+	  dummy = (byte & (1 << (i % BOOL_VECTOR_BITS_PER_CHAR))) ? Qt : Qnil;
 	  dummy = call1 (fn, dummy);
 	  if (vals)
 	    vals[i] = dummy;
@@ -4384,7 +4378,7 @@
   int i, old_size;
 
   xassert (VECTORP (vec));
-  old_size = XVECTOR (vec)->size;
+  old_size = ASIZE (vec);
   xassert (new_size >= old_size);
 
   v = allocate_vector (new_size);
@@ -4716,7 +4710,7 @@
 	if (!NILP (HASH_HASH (h, i)))
 	  {
 	    unsigned hash_code = XUINT (HASH_HASH (h, i));
-	    int start_of_bucket = hash_code % XVECTOR (h->index)->size;
+	    int start_of_bucket = hash_code % ASIZE (h->index);
 	    HASH_NEXT (h, i) = HASH_INDEX (h, start_of_bucket);
 	    HASH_INDEX (h, start_of_bucket) = make_number (i);
 	  }
@@ -4742,7 +4736,7 @@
   if (hash)
     *hash = hash_code;
 
-  start_of_bucket = hash_code % XVECTOR (h->index)->size;
+  start_of_bucket = hash_code % ASIZE (h->index);
   idx = HASH_INDEX (h, start_of_bucket);
 
   /* We need not gcpro idx since it's either an integer or nil.  */
@@ -4789,7 +4783,7 @@
   HASH_HASH (h, i) = make_number (hash);
 
   /* Add new entry to its collision chain.  */
-  start_of_bucket = hash % XVECTOR (h->index)->size;
+  start_of_bucket = hash % ASIZE (h->index);
   HASH_NEXT (h, i) = HASH_INDEX (h, start_of_bucket);
   HASH_INDEX (h, start_of_bucket) = make_number (i);
   return i;
@@ -4808,7 +4802,7 @@
   Lisp_Object idx, prev;
 
   hash_code = h->hashfn (h, key);
-  start_of_bucket = hash_code % XVECTOR (h->index)->size;
+  start_of_bucket = hash_code % ASIZE (h->index);
   idx = HASH_INDEX (h, start_of_bucket);
   prev = Qnil;
 
@@ -4864,8 +4858,8 @@
 	  HASH_HASH (h, i) = Qnil;
 	}
 
-      for (i = 0; i < XVECTOR (h->index)->size; ++i)
-	XVECTOR (h->index)->contents[i] = Qnil;
+      for (i = 0; i < ASIZE (h->index); ++i)
+	AREF (h->index, i) = Qnil;
 
       h->next_free = make_number (0);
       h->count = make_number (0);
@@ -4890,7 +4884,7 @@
 {
   int bucket, n, marked;
 
-  n = XVECTOR (h->index)->size & ~ARRAY_MARK_FLAG;
+  n = ASIZE (h->index) & ~ARRAY_MARK_FLAG;
   marked = 0;
 
   for (bucket = 0; bucket < n; ++bucket)
@@ -5104,13 +5098,13 @@
      Lisp_Object vec;
      int depth;
 {
-  unsigned hash = XVECTOR (vec)->size;
+  unsigned hash = ASIZE (vec);
   int i, n;
 
-  n = min (SXHASH_MAX_LEN, XVECTOR (vec)->size);
+  n = min (SXHASH_MAX_LEN, ASIZE (vec));
   for (i = 0; i < n; ++i)
     {
-      unsigned hash2 = sxhash (XVECTOR (vec)->contents[i], depth + 1);
+      unsigned hash2 = sxhash (AREF (vec, i), depth + 1);
       hash = SXHASH_COMBINE (hash, hash2);
     }