1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-02 21:10:27 +02:00

Reuse SCM_BYTEVECTOR_TYPED_LENGTH in scm_array_get_handle

* libguile/bytevectors.h (SCM_BYTEVECTOR_TYPE_SIZE,
  SCM_BYTEVECTOR_TYPED_LENGTH): Moved from libguile/bytevectors.c.

* libguile/array-handle.c (scm_array_get_handle): Reuse
  SCM_BYTEVECTOR_TYPED_LENGTH.
This commit is contained in:
Daniel Llorens 2015-02-11 12:58:01 +01:00
parent 4e766795b2
commit 85ac9cce0a
3 changed files with 7 additions and 9 deletions

View file

@ -185,15 +185,13 @@ scm_array_get_handle (SCM array, scm_t_array_handle *h)
break; break;
case scm_tc7_bytevector: case scm_tc7_bytevector:
{ {
size_t byte_length, length, element_byte_size; size_t length;
scm_t_array_element_type element_type; scm_t_array_element_type element_type;
scm_t_vector_ref vref; scm_t_vector_ref vref;
scm_t_vector_set vset; scm_t_vector_set vset;
byte_length = scm_c_bytevector_length (array);
element_type = SCM_BYTEVECTOR_ELEMENT_TYPE (array); element_type = SCM_BYTEVECTOR_ELEMENT_TYPE (array);
element_byte_size = scm_i_array_element_type_sizes[element_type] / 8; length = SCM_BYTEVECTOR_TYPED_LENGTH (array);
length = byte_length / element_byte_size;
switch (element_type) switch (element_type)
{ {

View file

@ -192,11 +192,6 @@
#define SCM_BYTEVECTOR_SET_PARENT(_bv, _parent) \ #define SCM_BYTEVECTOR_SET_PARENT(_bv, _parent) \
SCM_SET_CELL_OBJECT_3 ((_bv), (_parent)) SCM_SET_CELL_OBJECT_3 ((_bv), (_parent))
#define SCM_BYTEVECTOR_TYPE_SIZE(var) \
(scm_i_array_element_type_sizes[SCM_BYTEVECTOR_ELEMENT_TYPE (var)]/8)
#define SCM_BYTEVECTOR_TYPED_LENGTH(var) \
(SCM_BYTEVECTOR_LENGTH (var) / SCM_BYTEVECTOR_TYPE_SIZE (var))
/* The empty bytevector. */ /* The empty bytevector. */
SCM scm_null_bytevector = SCM_UNSPECIFIED; SCM scm_null_bytevector = SCM_UNSPECIFIED;

View file

@ -129,6 +129,11 @@ SCM_API SCM scm_utf32_to_string (SCM, SCM);
#define SCM_BYTEVECTOR_CONTIGUOUS_P(_bv) \ #define SCM_BYTEVECTOR_CONTIGUOUS_P(_bv) \
(SCM_BYTEVECTOR_FLAGS (_bv) >> 8UL) (SCM_BYTEVECTOR_FLAGS (_bv) >> 8UL)
#define SCM_BYTEVECTOR_TYPE_SIZE(var) \
(scm_i_array_element_type_sizes[SCM_BYTEVECTOR_ELEMENT_TYPE (var)]/8)
#define SCM_BYTEVECTOR_TYPED_LENGTH(var) \
(SCM_BYTEVECTOR_LENGTH (var) / SCM_BYTEVECTOR_TYPE_SIZE (var))
/* Hint that is passed to `scm_gc_malloc ()' and friends. */ /* Hint that is passed to `scm_gc_malloc ()' and friends. */
#define SCM_GC_BYTEVECTOR "bytevector" #define SCM_GC_BYTEVECTOR "bytevector"