From 82d8f025b11137781ab8761145cf1e1894eb0c8e Mon Sep 17 00:00:00 2001 From: Daniel Llorens Date: Thu, 13 Feb 2020 12:26:19 +0100 Subject: Simplify vector constructor * libguile/vectors.c: Remove redundant list check. --- libguile/vectors.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/libguile/vectors.c b/libguile/vectors.c index add267cbd..81fb9bb6b 100644 --- a/libguile/vectors.c +++ b/libguile/vectors.c @@ -122,20 +122,16 @@ SCM_DEFINE (scm_vector, "vector", 0, 0, 1, "@end lisp") #define FUNC_NAME s_scm_vector { - SCM res; - SCM *data; - long i, len; - + long len; SCM_VALIDATE_LIST_COPYLEN (1, l, len); + + SCM res = scm_c_make_vector (len, SCM_UNSPECIFIED); + SCM *data = SCM_I_VECTOR_WELTS (res); - res = scm_c_make_vector (len, SCM_UNSPECIFIED); - data = SCM_I_VECTOR_WELTS (res); - i = 0; - while (scm_is_pair (l) && i < len) + for (long i=0; i < len; ++i) { data[i] = SCM_CAR (l); l = SCM_CDR (l); - i += 1; } return res; -- cgit v1.2.3