diff options
author | Andy Wingo <wingo@pobox.com> | 2009-02-01 11:25:51 +0100 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2009-02-01 11:25:51 +0100 |
commit | 5338b62b86f0158176ace6f0f96bc5796f6f17cd (patch) | |
tree | fb5a145908e1c2c64f9c3dd425db087c98ed95fd | |
parent | ac47d5f6399c54bcb39a01bb0ade83a614d625b4 (diff) | |
download | guile-5338b62b86f0158176ace6f0f96bc5796f6f17cd.tar.gz |
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!
-rw-r--r-- | libguile/vm-i-system.c | 11 |
1 files 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; } |