aboutsummaryrefslogtreecommitdiffstats
path: root/src/fns.c
diff options
context:
space:
mode:
authorPaul Eggert2013-11-13 18:39:28 -0800
committerPaul Eggert2013-11-13 18:39:28 -0800
commit2cf00efc1b0db0ddc26fa14239026dd2d12c7d59 (patch)
tree1bd3fcc233230eb7e2ffdee78da9433b3915623e /src/fns.c
parentd672ac3c611453c624948ed8cc2ced65cadc3400 (diff)
downloademacs-2cf00efc1b0db0ddc26fa14239026dd2d12c7d59.tar.gz
emacs-2cf00efc1b0db0ddc26fa14239026dd2d12c7d59.zip
Simplify, port and tune bool vector implementation.
* configure.ac (BITSIZEOF_SIZE_T, SIZEOF_SIZE_T): Remove. * src/alloc.c (bool_vector_exact_payload_bytes) (bool_vector_payload_bytes): Remove. (bool_vector_fill): Return its argument. * src/alloc.c (bool_vector_fill): * src/lread.c (read1): * src/print.c (print_object): Simplify by using bool_vector_bytes. * src/alloc.c (make_uninit_bool_vector): New function, broken out from Fmake_bool_vector. (Fmake_bool_vector): Use it. Use tail call. (make_uninit_bool_vector, vector_nbytes): Simplify size calculations. * src/data.c (BITS_PER_ULL): New constant. (ULLONG_MAX, count_one_bits_ll): Fall back on long counterparts if long long versions don't exist. (shift_right_ull): New function. (count_one_bits_word): New function, replacing popcount_bits_word macro. Don't assume that bits_word is no wider than long long. (count_one_bits_word, count_trailing_zero_bits): Don't assume that bits_word is no wider than long long. * src/data.c (bool_vector_binop_driver, bool_vector_not): * src/fns.c (Fcopy_sequence): * src/lread.c (read1): Create an uninitialized destination, to avoid needless work. (internal_equal): Simplify. (Ffillarray): Prefer tail call. * src/data.c (bool_vector_binop_driver): Don't assume bit vectors always contain at least one word. (bits_word_to_host_endian): Prefer if to #if. Don't assume chars are narrower than ints. * src/data.c (Fbool_vector_count_matches, Fbool_vector_count_matches_at): * src/fns.c (Fcopy_sequence): Simplify and tune. * src/lisp.h (bits_word, BITS_WORD_MAX, BITS_PER_BITS_WORD): Don't try to port to hosts where bits_word values have holes; the code wouldn't work there anyway. Verify this assumption, though. (bool_vector_bytes): New function. (make_uninit_bool_vector): New decl. (bool_vector_fill): Now returns Lisp_Object.
Diffstat (limited to 'src/fns.c')
-rw-r--r--src/fns.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/fns.c b/src/fns.c
index 44b70af6eb5..93829fb1d62 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -435,13 +435,10 @@ with the original. */)
435 435
436 if (BOOL_VECTOR_P (arg)) 436 if (BOOL_VECTOR_P (arg))
437 { 437 {
438 Lisp_Object val; 438 EMACS_INT nbits = bool_vector_size (arg);
439 ptrdiff_t size_in_chars 439 ptrdiff_t nbytes = bool_vector_bytes (nbits);
440 = ((bool_vector_size (arg) + BOOL_VECTOR_BITS_PER_CHAR - 1) 440 Lisp_Object val = make_uninit_bool_vector (nbits);
441 / BOOL_VECTOR_BITS_PER_CHAR); 441 memcpy (bool_vector_data (val), bool_vector_data (arg), nbytes);
442
443 val = Fmake_bool_vector (Flength (arg), Qnil);
444 memcpy (bool_vector_data (val), bool_vector_data (arg), size_in_chars);
445 return val; 442 return val;
446 } 443 }
447 444
@@ -2066,8 +2063,7 @@ internal_equal (Lisp_Object o1, Lisp_Object o2, int depth, bool props)
2066 if (size != bool_vector_size (o2)) 2063 if (size != bool_vector_size (o2))
2067 return 0; 2064 return 0;
2068 if (memcmp (bool_vector_data (o1), bool_vector_data (o2), 2065 if (memcmp (bool_vector_data (o1), bool_vector_data (o2),
2069 ((size + BOOL_VECTOR_BITS_PER_CHAR - 1) 2066 bool_vector_bytes (size)))
2070 / BOOL_VECTOR_BITS_PER_CHAR)))
2071 return 0; 2067 return 0;
2072 return 1; 2068 return 1;
2073 } 2069 }
@@ -2157,7 +2153,7 @@ ARRAY is a vector, string, char-table, or bool-vector. */)
2157 p[idx] = charval; 2153 p[idx] = charval;
2158 } 2154 }
2159 else if (BOOL_VECTOR_P (array)) 2155 else if (BOOL_VECTOR_P (array))
2160 bool_vector_fill (array, item); 2156 return bool_vector_fill (array, item);
2161 else 2157 else
2162 wrong_type_argument (Qarrayp, array); 2158 wrong_type_argument (Qarrayp, array);
2163 return array; 2159 return array;