diff options
Diffstat (limited to 'src/fns.c')
-rw-r--r-- | src/fns.c | 68 |
1 files changed, 31 insertions, 37 deletions
diff --git a/src/fns.c b/src/fns.c index e6b83b8e4e1..da2c43fd6a9 100644 --- a/src/fns.c +++ b/src/fns.c @@ -150,13 +150,13 @@ To get the number of bytes, use `string-bytes'. */) if (STRINGP (sequence)) XSETFASTINT (val, SCHARS (sequence)); else if (VECTORP (sequence)) - XSETFASTINT (val, XVECTOR (sequence)->size); + XSETFASTINT (val, ASIZE (sequence)); else if (CHAR_TABLE_P (sequence)) XSETFASTINT (val, MAX_CHAR); 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; @@ -389,9 +389,9 @@ Symbols are also allowed; their print names are used instead. */) /* "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 */ @@ -576,7 +576,7 @@ concat (nargs, args, target_type, last_special) if (VECTORP (this)) for (i = 0; i < len; i++) { - ch = XVECTOR (this)->contents[i]; + ch = AREF (this, i); CHECK_CHARACTER (ch); this_len_byte = CHAR_BYTES (XINT (ch)); result_len_byte += this_len_byte; @@ -727,7 +727,7 @@ concat (nargs, args, target_type, last_special) thisindex++; } else - elt = XVECTOR (this)->contents[thisindex++]; + elt = AREF (this, thisindex++); /* Store this element into the result. */ if (toindex < 0) @@ -737,7 +737,7 @@ concat (nargs, args, target_type, last_special) tail = XCDR (tail); } else if (VECTORP (val)) - XVECTOR (val)->contents[toindex++] = elt; + AREF (val, toindex++) = elt; else { CHECK_NUMBER (elt); @@ -1180,7 +1180,7 @@ This function allows vectors as well as strings. */) size_byte = SBYTES (string); } else - size = XVECTOR (string)->size; + size = ASIZE (string); if (NILP (to)) { @@ -1218,8 +1218,7 @@ This function allows vectors as well as strings. */) 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; } @@ -1303,7 +1302,7 @@ substring_both (string, from, from_byte, to, to_byte) 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)); @@ -1317,8 +1316,7 @@ substring_both (string, from, from_byte, to, to_byte) string, make_number (0), res, Qnil); } else - res = Fvector (to - from, - XVECTOR (string)->contents + from); + res = Fvector (to - from, &AREF (string, from)); return res; } @@ -2180,11 +2178,11 @@ internal_equal (o1, o2, depth, props) 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)) @@ -2215,8 +2213,8 @@ internal_equal (o1, o2, depth, props) 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; } @@ -2257,7 +2255,7 @@ ARRAY is a vector, string, char-table, or bool-vector. */) 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; } @@ -2422,14 +2420,14 @@ mapcar1 (leni, vals, fn, seq) 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; } @@ -2440,11 +2438,7 @@ mapcar1 (leni, vals, fn, seq) { 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; @@ -3757,7 +3751,7 @@ larger_vector (vec, new_size, init) 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); @@ -4089,7 +4083,7 @@ maybe_resize_hash_table (h) 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); } @@ -4115,7 +4109,7 @@ hash_lookup (h, key, hash) 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. */ @@ -4162,7 +4156,7 @@ hash_put (h, key, value, hash) 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; @@ -4181,7 +4175,7 @@ hash_remove (h, key) 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; @@ -4237,8 +4231,8 @@ hash_clear (h) 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); @@ -4263,7 +4257,7 @@ sweep_weak_table (h, remove_entries_p) { 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) @@ -4477,13 +4471,13 @@ sxhash_vector (vec, depth) 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); } |