From 5338b62b86f0158176ace6f0f96bc5796f6f17cd Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Sun, 1 Feb 2009 11:25:51 +0100 Subject: [PATCH] don't make intermediate garbage when making vectors in the vm * libguile/vm-i-system.c (vector): Don't cons up a list just to make a vector. Saves a couple percent in total cell allocation when loading syncase. Probably not worth it, but foo! --- libguile/vm-i-system.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/libguile/vm-i-system.c b/libguile/vm-i-system.c index 179b6380a..002b0042e 100644 --- a/libguile/vm-i-system.c +++ b/libguile/vm-i-system.c @@ -160,9 +160,16 @@ VM_DEFINE_INSTRUCTION (16, vector, "vector", 2, -1, 1) unsigned h = FETCH (); unsigned l = FETCH (); unsigned len = ((h << 8) + l); - POP_LIST (len); + SCM vect; + SYNC_REGISTER (); - *sp = scm_vector (*sp); + sp++; sp -= len; + CHECK_UNDERFLOW (); + vect = scm_make_vector (scm_from_uint (len), SCM_BOOL_F); + memcpy (SCM_I_VECTOR_WELTS(vect), sp, sizeof(SCM) * len); + NULLSTACK (len); + *sp = vect; + NEXT; }