[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 01/23: Require vector as argument to vector-copy
From: |
Daniel Llorens |
Subject: |
[Guile-commits] 01/23: Require vector as argument to vector-copy |
Date: |
Mon, 10 Feb 2020 03:56:57 -0500 (EST) |
lloda pushed a commit to branch wip-vector-cleanup
in repository guile.
commit b6d8a7325270bfd8b449cd7b12ab561f20d37148
Author: Daniel Llorens <address@hidden>
AuthorDate: Mon Feb 3 11:21:20 2020 +0100
Require vector as argument to vector-copy
* libguile/vectors.c: Require vector and simplify.
---
libguile/vectors.c | 22 ++++++----------------
1 file changed, 6 insertions(+), 16 deletions(-)
diff --git a/libguile/vectors.c b/libguile/vectors.c
index 1578841..e88354b 100644
--- a/libguile/vectors.c
+++ b/libguile/vectors.c
@@ -33,6 +33,7 @@
#include "numbers.h"
#include "pairs.h"
#include "vectors.h"
+#include <string.h>
#include "generalized-vectors.h"
@@ -265,22 +266,11 @@ SCM_DEFINE (scm_vector_copy, "vector-copy", 1, 0, 0,
"Return a copy of @var{vec}.")
#define FUNC_NAME s_scm_vector_copy
{
- scm_t_array_handle handle;
- size_t i, len;
- ssize_t inc;
- const SCM *src;
- SCM result, *dst;
-
- src = scm_vector_elements (vec, &handle, &len, &inc);
-
- result = scm_c_make_vector (len, SCM_UNDEFINED);
- dst = SCM_I_VECTOR_WELTS (result);
- for (i = 0; i < len; i++, src += inc)
- dst[i] = *src;
-
- scm_array_handle_release (&handle);
-
- return result;
+ SCM_VALIDATE_VECTOR(1, vec);
+ size_t len = SCM_I_VECTOR_LENGTH (vec);
+ SCM val = scm_c_make_vector (len, SCM_UNDEFINED);
+ memcpy (SCM_I_VECTOR_WELTS (val), SCM_I_VECTOR_ELTS (vec), len *
sizeof(SCM));
+ return val;
}
#undef FUNC_NAME
- [Guile-commits] branch wip-vector-cleanup updated (9e44157 -> bf2d6f9), Daniel Llorens, 2020/02/10
- [Guile-commits] 01/23: Require vector as argument to vector-copy,
Daniel Llorens <=
- [Guile-commits] 02/23: Require vector as argument to vector->list, Daniel Llorens, 2020/02/10
- [Guile-commits] 03/23: Require vector argument to scm_vector_elements, scm_vector_writable_elements, Daniel Llorens, 2020/02/10
- [Guile-commits] 08/23: Fix doc for last bitvector patch, Daniel Llorens, 2020/02/10
- [Guile-commits] 13/23: Move bitvector functions using array_handle to libguile/array-handle.[ch], Daniel Llorens, 2020/02/10
- [Guile-commits] 16/23: Pull generalized-vectors from under bitvector/string/vector, Daniel Llorens, 2020/02/10
- [Guile-commits] 05/23: Simple vectors are just vectors, Daniel Llorens, 2020/02/10
- [Guile-commits] 19/23: Remove generalized-vectors.[hc], Daniel Llorens, 2020/02/10
- [Guile-commits] 04/23: Remove the unused argument from scm_array_p, Daniel Llorens, 2020/02/10
- [Guile-commits] 07/23: Simplify interfaces to scm_bitvector_elements and scm_bitvector_writable_elements, Daniel Llorens, 2020/02/10
- [Guile-commits] 23/23: Remove 'contiguous' flag in arrays, Daniel Llorens, 2020/02/10