[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 27/27: Reuse SCM_ASSERT_RANGE in scm_c_vector_ref, scm_c
From: |
Daniel Llorens |
Subject: |
[Guile-commits] 27/27: Reuse SCM_ASSERT_RANGE in scm_c_vector_ref, scm_c_vector_set_x |
Date: |
Thu, 9 Apr 2020 11:00:12 -0400 (EDT) |
lloda pushed a commit to branch wip-vector-cleanup
in repository guile.
commit 4636eb22636f0806a9e49b212e8206ba71b7985b
Author: Daniel Llorens <address@hidden>
AuthorDate: Thu Feb 13 13:05:09 2020 +0100
Reuse SCM_ASSERT_RANGE in scm_c_vector_ref, scm_c_vector_set_x
---
libguile/vectors.c | 18 ++++--------------
1 file changed, 4 insertions(+), 14 deletions(-)
diff --git a/libguile/vectors.c b/libguile/vectors.c
index 81fb9bb..d9d040a 100644
--- a/libguile/vectors.c
+++ b/libguile/vectors.c
@@ -162,10 +162,7 @@ scm_c_vector_ref (SCM v, size_t k)
#define FUNC_NAME s_scm_vector_ref
{
SCM_VALIDATE_VECTOR (1, v);
-
- if (k >= SCM_I_VECTOR_LENGTH (v))
- scm_out_of_range (NULL, scm_from_size_t (k));
-
+ SCM_ASSERT_RANGE (2, scm_from_size_t (k), k < SCM_I_VECTOR_LENGTH (v));
return SCM_VECTOR_REF (v, k);
}
#undef FUNC_NAME
@@ -193,10 +190,7 @@ scm_c_vector_set_x (SCM v, size_t k, SCM obj)
#define FUNC_NAME s_scm_vector_set_x
{
SCM_VALIDATE_MUTABLE_VECTOR (1, v);
-
- if (k >= SCM_I_VECTOR_LENGTH (v))
- scm_out_of_range (NULL, scm_from_size_t (k));
-
+ SCM_ASSERT_RANGE (2, scm_from_size_t (k), k < SCM_I_VECTOR_LENGTH (v));
SCM_VECTOR_SET (v, k, obj);
}
#undef FUNC_NAME
@@ -228,13 +222,9 @@ SCM
scm_c_make_vector (size_t k, SCM fill)
#define FUNC_NAME s_scm_make_vector
{
- SCM vector;
- size_t j;
-
SCM_ASSERT_RANGE (1, scm_from_size_t (k), k <= VECTOR_MAX_LENGTH);
-
- vector = make_vector (k);
- for (j = 0; j < k; ++j)
+ SCM vector = make_vector (k);
+ for (size_t j = 0; j < k; ++j)
SCM_VECTOR_SET (vector, j, fill);
return vector;
- [Guile-commits] 15/27: Rewrite vector-copy! using memmove, (continued)
- [Guile-commits] 15/27: Rewrite vector-copy! using memmove, Daniel Llorens, 2020/04/09
- [Guile-commits] 12/27: Remove generalized vector support for vector-move-right!, vector-move-left!, Daniel Llorens, 2020/04/09
- [Guile-commits] 22/27: Remove scm_from_contiguous_typed_array, Daniel Llorens, 2020/04/09
- [Guile-commits] 13/27: Move bitvector functions using array_handle to libguile/array-handle.[ch], Daniel Llorens, 2020/04/09
- [Guile-commits] 18/27: Pull generalized-vectors from under bytevectors, Daniel Llorens, 2020/04/09
- [Guile-commits] 25/27: Remove superfluous type check in bitvector->list, Daniel Llorens, 2020/04/09
- [Guile-commits] 26/27: Simplify vector constructor, Daniel Llorens, 2020/04/09
- [Guile-commits] 23/27: Remove 'contiguous' flag in arrays, Daniel Llorens, 2020/04/09
- [Guile-commits] 24/27: Move uniform-array->bytevector from (rnrs bytevectors) to core, Daniel Llorens, 2020/04/09
- [Guile-commits] 20/27: Update branch news file, Daniel Llorens, 2020/04/09
- [Guile-commits] 27/27: Reuse SCM_ASSERT_RANGE in scm_c_vector_ref, scm_c_vector_set_x,
Daniel Llorens <=
- [Guile-commits] 21/27: Merge generalized-arrays.[ch] in arrays.[ch], Daniel Llorens, 2020/04/09