[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 01/27: Require vector as argument to vector-copy
From: |
Daniel Llorens |
Subject: |
[Guile-commits] 01/27: Require vector as argument to vector-copy |
Date: |
Fri, 21 Feb 2020 03:56:56 -0500 (EST) |
lloda pushed a commit to branch wip-vector-cleanup
in repository guile.
commit e7d95862203707d2909d46874d231cafc292bf34
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 (6c995bc -> fb71aaf), Daniel Llorens, 2020/02/21
- [Guile-commits] 04/27: Remove the unused argument from scm_array_p, Daniel Llorens, 2020/02/21
- [Guile-commits] 10/27: Add lenp parameter back to scm_vector_(writable_)elements, Daniel Llorens, 2020/02/21
- [Guile-commits] 11/27: Add lenp parameter back to scm_bitvector_(writable_)elements, Daniel Llorens, 2020/02/21
- [Guile-commits] 13/27: Move bitvector functions using array_handle to libguile/array-handle.[ch], Daniel Llorens, 2020/02/21
- [Guile-commits] 02/27: Require vector as argument to vector->list, Daniel Llorens, 2020/02/21
- [Guile-commits] 03/27: Require vector argument to scm_vector_elements, scm_vector_writable_elements, Daniel Llorens, 2020/02/21
- [Guile-commits] 01/27: Require vector as argument to vector-copy,
Daniel Llorens <=
- [Guile-commits] 08/27: Fix doc for last bitvector patch, Daniel Llorens, 2020/02/21
- [Guile-commits] 06/27: Simplify interfaces to scm_vector_elements and scm_vector_writable_elements, Daniel Llorens, 2020/02/21
- [Guile-commits] 20/27: Update branch news file, Daniel Llorens, 2020/02/21
- [Guile-commits] 17/27: Pull generalized-vectors from under typed vectors, Daniel Llorens, 2020/02/21
- [Guile-commits] 16/27: Pull generalized-vectors from under bitvector/string/vector, Daniel Llorens, 2020/02/21
- [Guile-commits] 18/27: Pull generalized-vectors from under bytevectors, Daniel Llorens, 2020/02/21
- [Guile-commits] 14/27: Golf in srfi-4.h, Daniel Llorens, 2020/02/21
- [Guile-commits] 12/27: Remove generalized vector support for vector-move-right!, vector-move-left!, Daniel Llorens, 2020/02/21
- [Guile-commits] 15/27: Rewrite vector-copy! using memmove, Daniel Llorens, 2020/02/21
- [Guile-commits] 26/27: Simplify vector constructor, Daniel Llorens, 2020/02/21