[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 04/11: Reuse SCM_BYTEVECTOR_TYPED_LENGTH in scm_array_ge
From: |
Daniel Llorens |
Subject: |
[Guile-commits] 04/11: Reuse SCM_BYTEVECTOR_TYPED_LENGTH in scm_array_get_handle |
Date: |
Fri, 18 Nov 2016 11:03:39 +0000 (UTC) |
lloda pushed a commit to branch lloda-squash0
in repository guile.
commit 5cc1454b0f113c2b437d38295345676962f5eee3
Author: Daniel Llorens <address@hidden>
Date: Wed Feb 11 12:58:01 2015 +0100
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.
---
libguile/array-handle.c | 6 ++----
libguile/bytevectors.c | 5 -----
libguile/bytevectors.h | 5 +++++
3 files changed, 7 insertions(+), 9 deletions(-)
diff --git a/libguile/array-handle.c b/libguile/array-handle.c
index 2252ecc..3595266 100644
--- a/libguile/array-handle.c
+++ b/libguile/array-handle.c
@@ -185,15 +185,13 @@ scm_array_get_handle (SCM array, scm_t_array_handle *h)
break;
case scm_tc7_bytevector:
{
- size_t byte_length, length, element_byte_size;
+ size_t length;
scm_t_array_element_type element_type;
scm_t_vector_ref vref;
scm_t_vector_set vset;
- byte_length = scm_c_bytevector_length (array);
element_type = SCM_BYTEVECTOR_ELEMENT_TYPE (array);
- element_byte_size = scm_i_array_element_type_sizes[element_type] / 8;
- length = byte_length / element_byte_size;
+ length = SCM_BYTEVECTOR_TYPED_LENGTH (array);
switch (element_type)
{
diff --git a/libguile/bytevectors.c b/libguile/bytevectors.c
index e426ae3..cf247dc 100644
--- a/libguile/bytevectors.c
+++ b/libguile/bytevectors.c
@@ -192,11 +192,6 @@
#define SCM_BYTEVECTOR_SET_PARENT(_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. */
SCM scm_null_bytevector = SCM_UNSPECIFIED;
diff --git a/libguile/bytevectors.h b/libguile/bytevectors.h
index a5eeaea..af4ac1c 100644
--- a/libguile/bytevectors.h
+++ b/libguile/bytevectors.h
@@ -129,6 +129,11 @@ SCM_API SCM scm_utf32_to_string (SCM, SCM);
#define SCM_BYTEVECTOR_CONTIGUOUS_P(_bv) \
(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. */
#define SCM_GC_BYTEVECTOR "bytevector"
- [Guile-commits] branch lloda-squash0 updated (018579c -> a5bb9da), Daniel Llorens, 2016/11/18
- [Guile-commits] 04/11: Reuse SCM_BYTEVECTOR_TYPED_LENGTH in scm_array_get_handle,
Daniel Llorens <=
- [Guile-commits] 02/11: Remove scm_from_contiguous_array, array 'contiguous' flag, Daniel Llorens, 2016/11/18
- [Guile-commits] 03/11: Avoid unneeded internal use of array handles, Daniel Llorens, 2016/11/18
- [Guile-commits] 05/11: Remove deprecated array functions, Daniel Llorens, 2016/11/18
- [Guile-commits] 09/11: Special case for array-map! with three arguments, Daniel Llorens, 2016/11/18
- [Guile-commits] 07/11: Do not use array handles in scm_vector, Daniel Llorens, 2016/11/18
- [Guile-commits] 08/11: Speed up for multi-arg cases of scm_ramap functions, Daniel Llorens, 2016/11/18
- [Guile-commits] 10/11: New functions array-from, array-from*, array-amend!, Daniel Llorens, 2016/11/18
- [Guile-commits] 01/11: Fix compilation of rank 0 typed array literals, Daniel Llorens, 2016/11/18
- [Guile-commits] 06/11: Support typed arrays in some sort functions, Daniel Llorens, 2016/11/18
- [Guile-commits] 11/11: New functions (array-for-each-cell, array-for-each-cell-in-order), Daniel Llorens, 2016/11/18