diff options
| author | Stefan Monnier | 2006-11-24 18:42:14 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2006-11-24 18:42:14 +0000 |
| commit | 7edbb0da2b9f420ebcc5cd53ff4603cb601c6608 (patch) | |
| tree | ebd01c23a8dd4a5e6eae80e709bab19c1428dc7c /src/fns.c | |
| parent | 96215ace929fdb6c283a6a836e33a6b9b6cca5c2 (diff) | |
| download | emacs-7edbb0da2b9f420ebcc5cd53ff4603cb601c6608.tar.gz emacs-7edbb0da2b9f420ebcc5cd53ff4603cb601c6608.zip | |
Use AREF/ASIZE macros.
(concat): Provide the full ANSI prototype.
Diffstat (limited to 'src/fns.c')
| -rw-r--r-- | src/fns.c | 72 |
1 files changed, 33 insertions, 39 deletions
| @@ -150,7 +150,7 @@ To get the number of bytes, use `string-bytes'. */) | |||
| 150 | if (STRINGP (sequence)) | 150 | if (STRINGP (sequence)) |
| 151 | XSETFASTINT (val, SCHARS (sequence)); | 151 | XSETFASTINT (val, SCHARS (sequence)); |
| 152 | else if (VECTORP (sequence)) | 152 | else if (VECTORP (sequence)) |
| 153 | XSETFASTINT (val, XVECTOR (sequence)->size); | 153 | XSETFASTINT (val, ASIZE (sequence)); |
| 154 | else if (SUB_CHAR_TABLE_P (sequence)) | 154 | else if (SUB_CHAR_TABLE_P (sequence)) |
| 155 | XSETFASTINT (val, SUB_CHAR_TABLE_ORDINARY_SLOTS); | 155 | XSETFASTINT (val, SUB_CHAR_TABLE_ORDINARY_SLOTS); |
| 156 | else if (CHAR_TABLE_P (sequence)) | 156 | else if (CHAR_TABLE_P (sequence)) |
| @@ -158,7 +158,7 @@ To get the number of bytes, use `string-bytes'. */) | |||
| 158 | else if (BOOL_VECTOR_P (sequence)) | 158 | else if (BOOL_VECTOR_P (sequence)) |
| 159 | XSETFASTINT (val, XBOOL_VECTOR (sequence)->size); | 159 | XSETFASTINT (val, XBOOL_VECTOR (sequence)->size); |
| 160 | else if (COMPILEDP (sequence)) | 160 | else if (COMPILEDP (sequence)) |
| 161 | XSETFASTINT (val, XVECTOR (sequence)->size & PSEUDOVECTOR_SIZE_MASK); | 161 | XSETFASTINT (val, ASIZE (sequence) & PSEUDOVECTOR_SIZE_MASK); |
| 162 | else if (CONSP (sequence)) | 162 | else if (CONSP (sequence)) |
| 163 | { | 163 | { |
| 164 | i = 0; | 164 | i = 0; |
| @@ -391,9 +391,9 @@ Symbols are also allowed; their print names are used instead. */) | |||
| 391 | /* "gcc -O3" enables automatic function inlining, which optimizes out | 391 | /* "gcc -O3" enables automatic function inlining, which optimizes out |
| 392 | the arguments for the invocations of this function, whereas it | 392 | the arguments for the invocations of this function, whereas it |
| 393 | expects these values on the stack. */ | 393 | expects these values on the stack. */ |
| 394 | static Lisp_Object concat () __attribute__((noinline)); | 394 | static Lisp_Object concat P_ ((int nargs, Lisp_Object *args, enum Lisp_Type target_type, int last_special)) __attribute__((noinline)); |
| 395 | #else /* !__GNUC__ */ | 395 | #else /* !__GNUC__ */ |
| 396 | static Lisp_Object concat (); | 396 | static Lisp_Object concat P_ ((int nargs, Lisp_Object *args, enum Lisp_Type target_type, int last_special)); |
| 397 | #endif | 397 | #endif |
| 398 | 398 | ||
| 399 | /* ARGSUSED */ | 399 | /* ARGSUSED */ |
| @@ -617,7 +617,7 @@ concat (nargs, args, target_type, last_special) | |||
| 617 | if (VECTORP (this)) | 617 | if (VECTORP (this)) |
| 618 | for (i = 0; i < len; i++) | 618 | for (i = 0; i < len; i++) |
| 619 | { | 619 | { |
| 620 | ch = XVECTOR (this)->contents[i]; | 620 | ch = AREF (this, i); |
| 621 | CHECK_NUMBER (ch); | 621 | CHECK_NUMBER (ch); |
| 622 | this_len_byte = CHAR_BYTES (XINT (ch)); | 622 | this_len_byte = CHAR_BYTES (XINT (ch)); |
| 623 | result_len_byte += this_len_byte; | 623 | result_len_byte += this_len_byte; |
| @@ -770,7 +770,7 @@ concat (nargs, args, target_type, last_special) | |||
| 770 | thisindex++; | 770 | thisindex++; |
| 771 | } | 771 | } |
| 772 | else | 772 | else |
| 773 | elt = XVECTOR (this)->contents[thisindex++]; | 773 | elt = AREF (this, thisindex++); |
| 774 | 774 | ||
| 775 | /* Store this element into the result. */ | 775 | /* Store this element into the result. */ |
| 776 | if (toindex < 0) | 776 | if (toindex < 0) |
| @@ -780,7 +780,7 @@ concat (nargs, args, target_type, last_special) | |||
| 780 | tail = XCDR (tail); | 780 | tail = XCDR (tail); |
| 781 | } | 781 | } |
| 782 | else if (VECTORP (val)) | 782 | else if (VECTORP (val)) |
| 783 | XVECTOR (val)->contents[toindex++] = elt; | 783 | AREF (val, toindex++) = elt; |
| 784 | else | 784 | else |
| 785 | { | 785 | { |
| 786 | CHECK_NUMBER (elt); | 786 | CHECK_NUMBER (elt); |
| @@ -1261,7 +1261,7 @@ This function allows vectors as well as strings. */) | |||
| 1261 | size_byte = SBYTES (string); | 1261 | size_byte = SBYTES (string); |
| 1262 | } | 1262 | } |
| 1263 | else | 1263 | else |
| 1264 | size = XVECTOR (string)->size; | 1264 | size = ASIZE (string); |
| 1265 | 1265 | ||
| 1266 | if (NILP (to)) | 1266 | if (NILP (to)) |
| 1267 | { | 1267 | { |
| @@ -1299,8 +1299,7 @@ This function allows vectors as well as strings. */) | |||
| 1299 | string, make_number (0), res, Qnil); | 1299 | string, make_number (0), res, Qnil); |
| 1300 | } | 1300 | } |
| 1301 | else | 1301 | else |
| 1302 | res = Fvector (to_char - from_char, | 1302 | res = Fvector (to_char - from_char, &AREF (string, from_char)); |
| 1303 | XVECTOR (string)->contents + from_char); | ||
| 1304 | 1303 | ||
| 1305 | return res; | 1304 | return res; |
| 1306 | } | 1305 | } |
| @@ -1384,7 +1383,7 @@ substring_both (string, from, from_byte, to, to_byte) | |||
| 1384 | size_byte = SBYTES (string); | 1383 | size_byte = SBYTES (string); |
| 1385 | } | 1384 | } |
| 1386 | else | 1385 | else |
| 1387 | size = XVECTOR (string)->size; | 1386 | size = ASIZE (string); |
| 1388 | 1387 | ||
| 1389 | if (!(0 <= from && from <= to && to <= size)) | 1388 | if (!(0 <= from && from <= to && to <= size)) |
| 1390 | args_out_of_range_3 (string, make_number (from), make_number (to)); | 1389 | args_out_of_range_3 (string, make_number (from), make_number (to)); |
| @@ -1398,8 +1397,7 @@ substring_both (string, from, from_byte, to, to_byte) | |||
| 1398 | string, make_number (0), res, Qnil); | 1397 | string, make_number (0), res, Qnil); |
| 1399 | } | 1398 | } |
| 1400 | else | 1399 | else |
| 1401 | res = Fvector (to - from, | 1400 | res = Fvector (to - from, AREF (string, from)); |
| 1402 | XVECTOR (string)->contents + from); | ||
| 1403 | 1401 | ||
| 1404 | return res; | 1402 | return res; |
| 1405 | } | 1403 | } |
| @@ -2245,11 +2243,11 @@ internal_equal (o1, o2, depth, props) | |||
| 2245 | case Lisp_Vectorlike: | 2243 | case Lisp_Vectorlike: |
| 2246 | { | 2244 | { |
| 2247 | register int i; | 2245 | register int i; |
| 2248 | EMACS_INT size = XVECTOR (o1)->size; | 2246 | EMACS_INT size = ASIZE (o1); |
| 2249 | /* Pseudovectors have the type encoded in the size field, so this test | 2247 | /* Pseudovectors have the type encoded in the size field, so this test |
| 2250 | actually checks that the objects have the same type as well as the | 2248 | actually checks that the objects have the same type as well as the |
| 2251 | same size. */ | 2249 | same size. */ |
| 2252 | if (XVECTOR (o2)->size != size) | 2250 | if (ASIZE (o2) != size) |
| 2253 | return 0; | 2251 | return 0; |
| 2254 | /* Boolvectors are compared much like strings. */ | 2252 | /* Boolvectors are compared much like strings. */ |
| 2255 | if (BOOL_VECTOR_P (o1)) | 2253 | if (BOOL_VECTOR_P (o1)) |
| @@ -2279,8 +2277,8 @@ internal_equal (o1, o2, depth, props) | |||
| 2279 | for (i = 0; i < size; i++) | 2277 | for (i = 0; i < size; i++) |
| 2280 | { | 2278 | { |
| 2281 | Lisp_Object v1, v2; | 2279 | Lisp_Object v1, v2; |
| 2282 | v1 = XVECTOR (o1)->contents [i]; | 2280 | v1 = AREF (o1, i); |
| 2283 | v2 = XVECTOR (o2)->contents [i]; | 2281 | v2 = AREF (o2, i); |
| 2284 | if (!internal_equal (v1, v2, depth + 1, props)) | 2282 | if (!internal_equal (v1, v2, depth + 1, props)) |
| 2285 | return 0; | 2283 | return 0; |
| 2286 | } | 2284 | } |
| @@ -2321,7 +2319,7 @@ ARRAY is a vector, string, char-table, or bool-vector. */) | |||
| 2321 | if (VECTORP (array)) | 2319 | if (VECTORP (array)) |
| 2322 | { | 2320 | { |
| 2323 | register Lisp_Object *p = XVECTOR (array)->contents; | 2321 | register Lisp_Object *p = XVECTOR (array)->contents; |
| 2324 | size = XVECTOR (array)->size; | 2322 | size = ASIZE (array); |
| 2325 | for (index = 0; index < size; index++) | 2323 | for (index = 0; index < size; index++) |
| 2326 | p[index] = item; | 2324 | p[index] = item; |
| 2327 | } | 2325 | } |
| @@ -2549,7 +2547,7 @@ Note that this function doesn't check the parent of CHAR-TABLE. */) | |||
| 2549 | 2547 | ||
| 2550 | charset_info = Fget (range, Qcharset); | 2548 | charset_info = Fget (range, Qcharset); |
| 2551 | CHECK_VECTOR (charset_info); | 2549 | CHECK_VECTOR (charset_info); |
| 2552 | charset_id = XINT (XVECTOR (charset_info)->contents[0]); | 2550 | charset_id = XINT (AREF (charset_info, 0)); |
| 2553 | ch = Fmake_char_internal (make_number (charset_id), | 2551 | ch = Fmake_char_internal (make_number (charset_id), |
| 2554 | make_number (0), make_number (0)); | 2552 | make_number (0), make_number (0)); |
| 2555 | } | 2553 | } |
| @@ -2675,7 +2673,7 @@ character set, or a character code. Return VALUE. */) | |||
| 2675 | Faset (char_table, range, value); | 2673 | Faset (char_table, range, value); |
| 2676 | else if (VECTORP (range)) | 2674 | else if (VECTORP (range)) |
| 2677 | { | 2675 | { |
| 2678 | int size = XVECTOR (range)->size; | 2676 | int size = ASIZE (range); |
| 2679 | Lisp_Object *val = XVECTOR (range)->contents; | 2677 | Lisp_Object *val = XVECTOR (range)->contents; |
| 2680 | Lisp_Object ch = Fmake_char_internal (size <= 0 ? Qnil : val[0], | 2678 | Lisp_Object ch = Fmake_char_internal (size <= 0 ? Qnil : val[0], |
| 2681 | size <= 1 ? Qnil : val[1], | 2679 | size <= 1 ? Qnil : val[1], |
| @@ -3061,14 +3059,14 @@ mapcar1 (leni, vals, fn, seq) | |||
| 3061 | else | 3059 | else |
| 3062 | GCPRO2 (fn, seq); | 3060 | GCPRO2 (fn, seq); |
| 3063 | /* We need not explicitly protect `tail' because it is used only on lists, and | 3061 | /* We need not explicitly protect `tail' because it is used only on lists, and |
| 3064 | 1) lists are not relocated and 2) the list is marked via `seq' so will not be freed */ | 3062 | 1) lists are not relocated and 2) the list is marked via `seq' so will not |
| 3063 | be freed */ | ||
| 3065 | 3064 | ||
| 3066 | if (VECTORP (seq)) | 3065 | if (VECTORP (seq)) |
| 3067 | { | 3066 | { |
| 3068 | for (i = 0; i < leni; i++) | 3067 | for (i = 0; i < leni; i++) |
| 3069 | { | 3068 | { |
| 3070 | dummy = XVECTOR (seq)->contents[i]; | 3069 | dummy = call1 (fn, AREF (seq, i)); |
| 3071 | dummy = call1 (fn, dummy); | ||
| 3072 | if (vals) | 3070 | if (vals) |
| 3073 | vals[i] = dummy; | 3071 | vals[i] = dummy; |
| 3074 | } | 3072 | } |
| @@ -3079,11 +3077,7 @@ mapcar1 (leni, vals, fn, seq) | |||
| 3079 | { | 3077 | { |
| 3080 | int byte; | 3078 | int byte; |
| 3081 | byte = XBOOL_VECTOR (seq)->data[i / BOOL_VECTOR_BITS_PER_CHAR]; | 3079 | byte = XBOOL_VECTOR (seq)->data[i / BOOL_VECTOR_BITS_PER_CHAR]; |
| 3082 | if (byte & (1 << (i % BOOL_VECTOR_BITS_PER_CHAR))) | 3080 | dummy = (byte & (1 << (i % BOOL_VECTOR_BITS_PER_CHAR))) ? Qt : Qnil; |
| 3083 | dummy = Qt; | ||
| 3084 | else | ||
| 3085 | dummy = Qnil; | ||
| 3086 | |||
| 3087 | dummy = call1 (fn, dummy); | 3081 | dummy = call1 (fn, dummy); |
| 3088 | if (vals) | 3082 | if (vals) |
| 3089 | vals[i] = dummy; | 3083 | vals[i] = dummy; |
| @@ -4384,7 +4378,7 @@ larger_vector (vec, new_size, init) | |||
| 4384 | int i, old_size; | 4378 | int i, old_size; |
| 4385 | 4379 | ||
| 4386 | xassert (VECTORP (vec)); | 4380 | xassert (VECTORP (vec)); |
| 4387 | old_size = XVECTOR (vec)->size; | 4381 | old_size = ASIZE (vec); |
| 4388 | xassert (new_size >= old_size); | 4382 | xassert (new_size >= old_size); |
| 4389 | 4383 | ||
| 4390 | v = allocate_vector (new_size); | 4384 | v = allocate_vector (new_size); |
| @@ -4716,7 +4710,7 @@ maybe_resize_hash_table (h) | |||
| 4716 | if (!NILP (HASH_HASH (h, i))) | 4710 | if (!NILP (HASH_HASH (h, i))) |
| 4717 | { | 4711 | { |
| 4718 | unsigned hash_code = XUINT (HASH_HASH (h, i)); | 4712 | unsigned hash_code = XUINT (HASH_HASH (h, i)); |
| 4719 | int start_of_bucket = hash_code % XVECTOR (h->index)->size; | 4713 | int start_of_bucket = hash_code % ASIZE (h->index); |
| 4720 | HASH_NEXT (h, i) = HASH_INDEX (h, start_of_bucket); | 4714 | HASH_NEXT (h, i) = HASH_INDEX (h, start_of_bucket); |
| 4721 | HASH_INDEX (h, start_of_bucket) = make_number (i); | 4715 | HASH_INDEX (h, start_of_bucket) = make_number (i); |
| 4722 | } | 4716 | } |
| @@ -4742,7 +4736,7 @@ hash_lookup (h, key, hash) | |||
| 4742 | if (hash) | 4736 | if (hash) |
| 4743 | *hash = hash_code; | 4737 | *hash = hash_code; |
| 4744 | 4738 | ||
| 4745 | start_of_bucket = hash_code % XVECTOR (h->index)->size; | 4739 | start_of_bucket = hash_code % ASIZE (h->index); |
| 4746 | idx = HASH_INDEX (h, start_of_bucket); | 4740 | idx = HASH_INDEX (h, start_of_bucket); |
| 4747 | 4741 | ||
| 4748 | /* We need not gcpro idx since it's either an integer or nil. */ | 4742 | /* We need not gcpro idx since it's either an integer or nil. */ |
| @@ -4789,7 +4783,7 @@ hash_put (h, key, value, hash) | |||
| 4789 | HASH_HASH (h, i) = make_number (hash); | 4783 | HASH_HASH (h, i) = make_number (hash); |
| 4790 | 4784 | ||
| 4791 | /* Add new entry to its collision chain. */ | 4785 | /* Add new entry to its collision chain. */ |
| 4792 | start_of_bucket = hash % XVECTOR (h->index)->size; | 4786 | start_of_bucket = hash % ASIZE (h->index); |
| 4793 | HASH_NEXT (h, i) = HASH_INDEX (h, start_of_bucket); | 4787 | HASH_NEXT (h, i) = HASH_INDEX (h, start_of_bucket); |
| 4794 | HASH_INDEX (h, start_of_bucket) = make_number (i); | 4788 | HASH_INDEX (h, start_of_bucket) = make_number (i); |
| 4795 | return i; | 4789 | return i; |
| @@ -4808,7 +4802,7 @@ hash_remove (h, key) | |||
| 4808 | Lisp_Object idx, prev; | 4802 | Lisp_Object idx, prev; |
| 4809 | 4803 | ||
| 4810 | hash_code = h->hashfn (h, key); | 4804 | hash_code = h->hashfn (h, key); |
| 4811 | start_of_bucket = hash_code % XVECTOR (h->index)->size; | 4805 | start_of_bucket = hash_code % ASIZE (h->index); |
| 4812 | idx = HASH_INDEX (h, start_of_bucket); | 4806 | idx = HASH_INDEX (h, start_of_bucket); |
| 4813 | prev = Qnil; | 4807 | prev = Qnil; |
| 4814 | 4808 | ||
| @@ -4864,8 +4858,8 @@ hash_clear (h) | |||
| 4864 | HASH_HASH (h, i) = Qnil; | 4858 | HASH_HASH (h, i) = Qnil; |
| 4865 | } | 4859 | } |
| 4866 | 4860 | ||
| 4867 | for (i = 0; i < XVECTOR (h->index)->size; ++i) | 4861 | for (i = 0; i < ASIZE (h->index); ++i) |
| 4868 | XVECTOR (h->index)->contents[i] = Qnil; | 4862 | AREF (h->index, i) = Qnil; |
| 4869 | 4863 | ||
| 4870 | h->next_free = make_number (0); | 4864 | h->next_free = make_number (0); |
| 4871 | h->count = make_number (0); | 4865 | h->count = make_number (0); |
| @@ -4890,7 +4884,7 @@ sweep_weak_table (h, remove_entries_p) | |||
| 4890 | { | 4884 | { |
| 4891 | int bucket, n, marked; | 4885 | int bucket, n, marked; |
| 4892 | 4886 | ||
| 4893 | n = XVECTOR (h->index)->size & ~ARRAY_MARK_FLAG; | 4887 | n = ASIZE (h->index) & ~ARRAY_MARK_FLAG; |
| 4894 | marked = 0; | 4888 | marked = 0; |
| 4895 | 4889 | ||
| 4896 | for (bucket = 0; bucket < n; ++bucket) | 4890 | for (bucket = 0; bucket < n; ++bucket) |
| @@ -5104,13 +5098,13 @@ sxhash_vector (vec, depth) | |||
| 5104 | Lisp_Object vec; | 5098 | Lisp_Object vec; |
| 5105 | int depth; | 5099 | int depth; |
| 5106 | { | 5100 | { |
| 5107 | unsigned hash = XVECTOR (vec)->size; | 5101 | unsigned hash = ASIZE (vec); |
| 5108 | int i, n; | 5102 | int i, n; |
| 5109 | 5103 | ||
| 5110 | n = min (SXHASH_MAX_LEN, XVECTOR (vec)->size); | 5104 | n = min (SXHASH_MAX_LEN, ASIZE (vec)); |
| 5111 | for (i = 0; i < n; ++i) | 5105 | for (i = 0; i < n; ++i) |
| 5112 | { | 5106 | { |
| 5113 | unsigned hash2 = sxhash (XVECTOR (vec)->contents[i], depth + 1); | 5107 | unsigned hash2 = sxhash (AREF (vec, i), depth + 1); |
| 5114 | hash = SXHASH_COMBINE (hash, hash2); | 5108 | hash = SXHASH_COMBINE (hash, hash2); |
| 5115 | } | 5109 | } |
| 5116 | 5110 | ||