summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2018-03-12 17:51:28 -0700
committerKaz Kylheku <kaz@kylheku.com>2018-03-12 17:51:28 -0700
commit8678e098fca4132ce158d4a5ab82d0091d0568b2 (patch)
tree5e8dc88313f5192f7af98b1e9974b2eb2aa38e40
parent656a8eaea985f569376871a479ee1abf4d99d82e (diff)
downloadtxr-8678e098fca4132ce158d4a5ab82d0091d0568b2.tar.gz
txr-8678e098fca4132ce158d4a5ab82d0091d0568b2.tar.bz2
txr-8678e098fca4132ce158d4a5ab82d0091d0568b2.zip
vm: use memcpy for copying environment.
* vm.c (vm_make_closure): When copying captured environment from stack to heap, use memcpy instead of a loop with assignments.
-rw-r--r--vm.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/vm.c b/vm.c
index 1591644e..128b8f29 100644
--- a/vm.c
+++ b/vm.c
@@ -164,7 +164,7 @@ static val vm_make_closure(struct vm *vm, int frsz)
chk_calloc(vm->nlvl, sizeof *dspl));
struct vm_closure *vc = coerce(struct vm_closure *, chk_malloc(sizeof *vc));
val closure;
- int i, j;
+ int i;
vc->frsz = frsz;
vc->ip = vm->ip;
@@ -187,12 +187,10 @@ static val vm_make_closure(struct vm *vm, int frsz)
break;
case NUM:
{
- int n = c_num(vec);
val heap_vec = vector(vec, nil);
cdi->vec = heap_vec;
cdi->mem = heap_vec->v.vec;
- for (j = 0; j < n; j++)
- heap_vec->v.vec[j] = mem[j];
+ memcpy(heap_vec->v.vec, mem, c_num(vec));
mut(closure);
*sdi = *cdi;
break;