From e742498218793e4515c86717ed5e121e40f1fd57 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Mon, 12 Mar 2018 17:51:28 -0700 Subject: 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. --- vm.c | 6 ++---- 1 file 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; -- cgit v1.2.3