From d9b300cb701b20f65ec2d41af911a3b6881ffe2d Mon Sep 17 00:00:00 2001 From: Ralph Caraveo III Date: Tue, 21 Sep 2021 05:47:21 -0700 Subject: [PATCH] For the OpMap VM instruction, since numElements is known just use the capacity hint. (#347) --- vm.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vm.go b/vm.go index 811ecef..c836525 100644 --- a/vm.go +++ b/vm.go @@ -293,7 +293,7 @@ func (v *VM) run() { case parser.OpMap: v.ip += 2 numElements := int(v.curInsts[v.ip]) | int(v.curInsts[v.ip-1])<<8 - kv := make(map[string]Object) + kv := make(map[string]Object, numElements) for i := v.sp - numElements; i < v.sp; i += 2 { key := v.stack[i] value := v.stack[i+1]