[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 07/11: Do not use array handles in scm_vector
From: |
Daniel Llorens |
Subject: |
[Guile-commits] 07/11: Do not use array handles in scm_vector |
Date: |
Fri, 18 Nov 2016 11:03:40 +0000 (UTC) |
lloda pushed a commit to branch lloda-squash0
in repository guile.
commit 4070bceddfb21771132cb3f5e1e01f5b665a5be6
Author: Daniel Llorens <address@hidden>
Date: Wed Feb 25 09:47:40 2015 +0100
Do not use array handles in scm_vector
* libguile/vectors.c (scm_vector): Use SCM_I_VECTOR_WELTS on new vector
instead of generic scm_vector_elements; cf. scm_vector_copy().
(scm_vector_elements): Forward to scm_vector_writable_elements().
(scm_vector_writable_elements): Remove special error message for weak
vector arg.
* libguile/generalized-vectors.c (SCM_VALIDATE_VECTOR_WITH_HANDLE):
Remove unused macro.
* libguile/array-handle.c (scm_array_handle_elements): Forward to
scm_array_handle_writable_elements().
---
libguile/array-handle.c | 4 +---
libguile/generalized-vectors.c | 5 -----
libguile/vectors.c | 20 ++------------------
3 files changed, 3 insertions(+), 26 deletions(-)
diff --git a/libguile/array-handle.c b/libguile/array-handle.c
index 3595266..89277d9 100644
--- a/libguile/array-handle.c
+++ b/libguile/array-handle.c
@@ -320,9 +320,7 @@ scm_array_handle_release (scm_t_array_handle *h)
const SCM *
scm_array_handle_elements (scm_t_array_handle *h)
{
- if (h->element_type != SCM_ARRAY_ELEMENT_TYPE_SCM)
- scm_wrong_type_arg_msg (NULL, 0, h->array, "non-uniform array");
- return ((const SCM*)h->elements) + h->base;
+ return scm_array_handle_writable_elements (h);
}
SCM *
diff --git a/libguile/generalized-vectors.c b/libguile/generalized-vectors.c
index 0fe8b89..276b9d8 100644
--- a/libguile/generalized-vectors.c
+++ b/libguile/generalized-vectors.c
@@ -69,11 +69,6 @@ SCM_DEFINE (scm_make_generalized_vector,
"make-generalized-vector", 2, 1, 0,
}
#undef FUNC_NAME
-
-#define SCM_VALIDATE_VECTOR_WITH_HANDLE(pos, val, handle) \
- scm_generalized_vector_get_handle (val, handle)
-
-
void
scm_generalized_vector_get_handle (SCM vec, scm_t_array_handle *h)
{
diff --git a/libguile/vectors.c b/libguile/vectors.c
index 5dab545..6dcc7eb 100644
--- a/libguile/vectors.c
+++ b/libguile/vectors.c
@@ -59,26 +59,13 @@ const SCM *
scm_vector_elements (SCM vec, scm_t_array_handle *h,
size_t *lenp, ssize_t *incp)
{
- if (SCM_I_WVECTP (vec))
- scm_wrong_type_arg_msg (NULL, 0, vec, "non-weak vector");
-
- scm_generalized_vector_get_handle (vec, h);
- if (lenp)
- {
- scm_t_array_dim *dim = scm_array_handle_dims (h);
- *lenp = dim->ubnd - dim->lbnd + 1;
- *incp = dim->inc;
- }
- return scm_array_handle_elements (h);
+ return scm_vector_writable_elements (vec, h, lenp, incp);
}
SCM *
scm_vector_writable_elements (SCM vec, scm_t_array_handle *h,
size_t *lenp, ssize_t *incp)
{
- if (SCM_I_WVECTP (vec))
- scm_wrong_type_arg_msg (NULL, 0, vec, "non-weak vector");
-
scm_generalized_vector_get_handle (vec, h);
if (lenp)
{
@@ -141,12 +128,11 @@ SCM_DEFINE (scm_vector, "vector", 0, 0, 1,
SCM res;
SCM *data;
long i, len;
- scm_t_array_handle handle;
SCM_VALIDATE_LIST_COPYLEN (1, l, len);
res = scm_c_make_vector (len, SCM_UNSPECIFIED);
- data = scm_vector_writable_elements (res, &handle, NULL, NULL);
+ data = SCM_I_VECTOR_WELTS (res);
i = 0;
while (scm_is_pair (l) && i < len)
{
@@ -155,8 +141,6 @@ SCM_DEFINE (scm_vector, "vector", 0, 0, 1,
i += 1;
}
- scm_array_handle_release (&handle);
-
return res;
}
#undef FUNC_NAME
- [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, 2016/11/18
- [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 <=
- [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