Commit 1c0a7493 authored by Paul Eggert's avatar Paul Eggert

* lisp.h (bool_vector_size): New function.

All uses of XBOOL_VECTOR (x)->size changed to bool_vector_size (x).
* data.c (bool_vector_spare_mask, bool_vector_binop_driver)
(Fbool_vector_not, Fbool_vector_count_matches_at):
Remove uses of 'eassume' that should no longer be needed,
because they are subsumed by the 'eassume' in bool_vector_size.
parent 1eda1d8d
2013-10-14 Paul Eggert <eggert@cs.ucla.edu>
* lisp.h (bool_vector_size): New function.
All uses of XBOOL_VECTOR (x)->size changed to bool_vector_size (x).
* data.c (bool_vector_spare_mask, bool_vector_binop_driver)
(Fbool_vector_not, Fbool_vector_count_matches_at):
Remove uses of 'eassume' that should no longer be needed,
because they are subsumed by the 'eassume' in bool_vector_size.
2013-10-12 Eli Zaretskii <eliz@gnu.org>
* image.c (GIFLIB_MAJOR, GIFLIB_MINOR, GIFLIB_RELEASE): Move back
......
......@@ -63,7 +63,7 @@ INLINE_HEADER_BEGIN
#define XCATEGORY_SET XBOOL_VECTOR
#define CATEGORY_SET_P(x) \
(BOOL_VECTOR_P (x) && XBOOL_VECTOR (x)->size == 128)
(BOOL_VECTOR_P (x) && bool_vector_size (x) == 128)
/* Return a new empty category set. */
#define MAKE_CATEGORY_SET (Fmake_bool_vector (make_number (128), Qnil))
......
......@@ -2130,7 +2130,7 @@ or a byte-code object. IDX starts at 0. */)
{
int val;
if (idxval < 0 || idxval >= XBOOL_VECTOR (array)->size)
if (idxval < 0 || idxval >= bool_vector_size (array))
args_out_of_range (array, idx);
val = (unsigned char) XBOOL_VECTOR (array)->data[idxval / BOOL_VECTOR_BITS_PER_CHAR];
......@@ -2180,7 +2180,7 @@ bool-vector. IDX starts at 0. */)
{
int val;
if (idxval < 0 || idxval >= XBOOL_VECTOR (array)->size)
if (idxval < 0 || idxval >= bool_vector_size (array))
args_out_of_range (array, idx);
val = (unsigned char) XBOOL_VECTOR (array)->data[idxval / BOOL_VECTOR_BITS_PER_CHAR];
......@@ -2969,7 +2969,6 @@ lowercase l) for small endian machines. */)
static bits_word
bool_vector_spare_mask (ptrdiff_t nr_bits)
{
eassume (nr_bits > 0);
return (((bits_word) 1) << (nr_bits % BITS_PER_BITS_WORD)) - 1;
}
......@@ -3005,8 +3004,7 @@ bool_vector_binop_driver (Lisp_Object op1,
CHECK_BOOL_VECTOR (op1);
CHECK_BOOL_VECTOR (op2);
nr_bits = min (XBOOL_VECTOR (op1)->size,
XBOOL_VECTOR (op2)->size);
nr_bits = min (bool_vector_size (op1), bool_vector_size (op2));
if (NILP (dest))
{
......@@ -3016,10 +3014,9 @@ bool_vector_binop_driver (Lisp_Object op1,
else
{
CHECK_BOOL_VECTOR (dest);
nr_bits = min (nr_bits, XBOOL_VECTOR (dest)->size);
nr_bits = min (nr_bits, bool_vector_size (dest));
}
eassume (nr_bits >= 0);
nr_words = ROUNDUP (nr_bits, BITS_PER_BITS_WORD) / BITS_PER_BITS_WORD;
adata = (bits_word *) XBOOL_VECTOR (dest)->data;
......@@ -3172,21 +3169,19 @@ Return the destination vector. */)
bits_word mword;
CHECK_BOOL_VECTOR (a);
nr_bits = XBOOL_VECTOR (a)->size;
nr_bits = bool_vector_size (a);
if (NILP (b))
b = Fmake_bool_vector (make_number (nr_bits), Qnil);
else
{
CHECK_BOOL_VECTOR (b);
nr_bits = min (nr_bits, XBOOL_VECTOR (b)->size);
nr_bits = min (nr_bits, bool_vector_size (b));
}
bdata = (bits_word *) XBOOL_VECTOR (b)->data;
adata = (bits_word *) XBOOL_VECTOR (a)->data;
eassume (nr_bits >= 0);
for (i = 0; i < nr_bits / BITS_PER_BITS_WORD; i++)
bdata[i] = ~adata[i];
......@@ -3215,13 +3210,11 @@ A must be a bool vector. B is a generalized bool. */)
CHECK_BOOL_VECTOR (a);
nr_bits = XBOOL_VECTOR (a)->size;
nr_bits = bool_vector_size (a);
count = 0;
match = NILP (b) ? -1 : 0;
adata = (bits_word *) XBOOL_VECTOR (a)->data;
eassume (nr_bits >= 0);
for (i = 0; i < nr_bits / BITS_PER_BITS_WORD; ++i)
count += popcount_bits_word (adata[i] ^ match);
......@@ -3256,13 +3249,12 @@ index into the vector. */)
CHECK_BOOL_VECTOR (a);
CHECK_NATNUM (i);
nr_bits = XBOOL_VECTOR (a)->size;
nr_bits = bool_vector_size (a);
if (XFASTINT (i) > nr_bits) /* Allow one past the end for convenience */
args_out_of_range (a, i);
adata = (bits_word *) XBOOL_VECTOR (a)->data;
eassume (nr_bits >= 0);
nr_words = ROUNDUP (nr_bits, BITS_PER_BITS_WORD) / BITS_PER_BITS_WORD;
pos = XFASTINT (i) / BITS_PER_BITS_WORD;
......
......@@ -114,7 +114,7 @@ To get the number of bytes, use `string-bytes'. */)
else if (CHAR_TABLE_P (sequence))
XSETFASTINT (val, MAX_CHAR);
else if (BOOL_VECTOR_P (sequence))
XSETFASTINT (val, XBOOL_VECTOR (sequence)->size);
XSETFASTINT (val, bool_vector_size (sequence));
else if (COMPILEDP (sequence))
XSETFASTINT (val, ASIZE (sequence) & PSEUDOVECTOR_SIZE_MASK);
else if (CONSP (sequence))
......@@ -437,7 +437,7 @@ with the original. */)
{
Lisp_Object val;
ptrdiff_t size_in_chars
= ((XBOOL_VECTOR (arg)->size + BOOL_VECTOR_BITS_PER_CHAR - 1)
= ((bool_vector_size (arg) + BOOL_VECTOR_BITS_PER_CHAR - 1)
/ BOOL_VECTOR_BITS_PER_CHAR);
val = Fmake_bool_vector (Flength (arg), Qnil);
......@@ -540,7 +540,7 @@ concat (ptrdiff_t nargs, Lisp_Object *args,
if (! ASCII_CHAR_P (c) && ! CHAR_BYTE8_P (c))
some_multibyte = 1;
}
else if (BOOL_VECTOR_P (this) && XBOOL_VECTOR (this)->size > 0)
else if (BOOL_VECTOR_P (this) && bool_vector_size (this) > 0)
wrong_type_argument (Qintegerp, Faref (this, make_number (0)));
else if (CONSP (this))
for (; CONSP (this); this = XCDR (this))
......@@ -2070,11 +2070,11 @@ internal_equal (Lisp_Object o1, Lisp_Object o2, int depth, bool props)
/* Boolvectors are compared much like strings. */
if (BOOL_VECTOR_P (o1))
{
if (XBOOL_VECTOR (o1)->size != XBOOL_VECTOR (o2)->size)
EMACS_INT size = bool_vector_size (o1);
if (size != bool_vector_size (o2))
return 0;
if (memcmp (XBOOL_VECTOR (o1)->data, XBOOL_VECTOR (o2)->data,
((XBOOL_VECTOR (o1)->size
+ BOOL_VECTOR_BITS_PER_CHAR - 1)
((size + BOOL_VECTOR_BITS_PER_CHAR - 1)
/ BOOL_VECTOR_BITS_PER_CHAR)))
return 0;
return 1;
......@@ -2166,10 +2166,9 @@ ARRAY is a vector, string, char-table, or bool-vector. */)
}
else if (BOOL_VECTOR_P (array))
{
register unsigned char *p = XBOOL_VECTOR (array)->data;
size =
((XBOOL_VECTOR (array)->size + BOOL_VECTOR_BITS_PER_CHAR - 1)
/ BOOL_VECTOR_BITS_PER_CHAR);
unsigned char *p = XBOOL_VECTOR (array)->data;
size = ((bool_vector_size (array) + BOOL_VECTOR_BITS_PER_CHAR - 1)
/ BOOL_VECTOR_BITS_PER_CHAR);
if (size)
{
......@@ -4188,11 +4187,12 @@ sxhash_vector (Lisp_Object vec, int depth)
static EMACS_UINT
sxhash_bool_vector (Lisp_Object vec)
{
EMACS_UINT hash = XBOOL_VECTOR (vec)->size;
EMACS_INT size = bool_vector_size (vec);
EMACS_UINT hash = size;
int i, n;
n = min (SXHASH_MAX_LEN,
((XBOOL_VECTOR (vec)->size + BOOL_VECTOR_BITS_PER_CHAR - 1)
((size + BOOL_VECTOR_BITS_PER_CHAR - 1)
/ BOOL_VECTOR_BITS_PER_CHAR));
for (i = 0; i < n; ++i)
hash = sxhash_combine (hash, XBOOL_VECTOR (vec)->data[i]);
......
......@@ -2456,7 +2456,7 @@ xbm_image_p (Lisp_Object object)
}
else if (BOOL_VECTOR_P (elt))
{
if (XBOOL_VECTOR (elt)->size < width)
if (bool_vector_size (elt) < width)
return 0;
}
else
......@@ -2471,7 +2471,7 @@ xbm_image_p (Lisp_Object object)
}
else if (BOOL_VECTOR_P (data))
{
if (XBOOL_VECTOR (data)->size / height < width)
if (bool_vector_size (data) / height < width)
return 0;
}
else
......
......@@ -1184,6 +1184,14 @@ struct Lisp_Bool_Vector
unsigned char data[FLEXIBLE_ARRAY_MEMBER];
};
INLINE EMACS_INT
bool_vector_size (Lisp_Object a)
{
EMACS_INT size = XBOOL_VECTOR (a)->size;
eassume (0 <= size);
return size;
}
/* Some handy constants for calculating sizes
and offsets, mostly of vectorlike objects. */
......
......@@ -1704,15 +1704,14 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
int len;
unsigned char c;
struct gcpro gcpro1;
ptrdiff_t size_in_chars
= ((XBOOL_VECTOR (obj)->size + BOOL_VECTOR_BITS_PER_CHAR - 1)
/ BOOL_VECTOR_BITS_PER_CHAR);
EMACS_INT size = bool_vector_size (obj);
ptrdiff_t size_in_chars = ((size + BOOL_VECTOR_BITS_PER_CHAR - 1)
/ BOOL_VECTOR_BITS_PER_CHAR);
GCPRO1 (obj);
PRINTCHAR ('#');
PRINTCHAR ('&');
len = sprintf (buf, "%"pI"d", XBOOL_VECTOR (obj)->size);
len = sprintf (buf, "%"pI"d", size);
strout (buf, len, len, printcharfun);
PRINTCHAR ('\"');
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment