For the OpMap VM instruction, since numElements is known just use the capacity hint. (#347)
This commit is contained in:
parent
de6dc1e9a9
commit
d9b300cb70
1 changed files with 1 additions and 1 deletions
2
vm.go
2
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]
|
||||
|
|
Loading…
Reference in a new issue