@@ -1360,7 +1360,7 @@ func (c *Compiler) compileUpsert(local ir.Local, path []int, value ir.Operand, _
13601360 // Initialize the locals that specify the path of the upsert operation.
13611361 lpath := make (map [int ]uint32 , len (path ))
13621362
1363- for i := 0 ; i < len ( path ); i ++ {
1363+ for i := range path {
13641364 lpath [i ] = c .genLocal ()
13651365 instrs = append (instrs , instruction.I32Const {Value : c .opaStringAddr (path [i ])})
13661366 instrs = append (instrs , instruction.SetLocal {Index : lpath [i ]})
@@ -1369,10 +1369,10 @@ func (c *Compiler) compileUpsert(local ir.Local, path []int, value ir.Operand, _
13691369 // Generate a block that traverses the path of the upsert operation,
13701370 // shallowing copying values at each step as needed. Stop before the final
13711371 // segment that will only be inserted.
1372- var inner []instruction.Instruction
1372+ inner := make ( []instruction.Instruction , 0 , len ( path ) * 21 + 1 )
13731373 ltemp := c .genLocal ()
13741374
1375- for i := 0 ; i < len (path )- 1 ; i ++ {
1375+ for i := range len (path ) - 1 {
13761376
13771377 // Lookup the next part of the path.
13781378 inner = append (inner , instruction.GetLocal {Index : lcopy })
@@ -1408,10 +1408,10 @@ func (c *Compiler) compileUpsert(local ir.Local, path []int, value ir.Operand, _
14081408 inner = append (inner , instruction.Br {Index : uint32 (len (path ) - 1 )})
14091409
14101410 // Generate blocks that handle missing nodes during traversal.
1411- var block []instruction.Instruction
1411+ block := make ( []instruction.Instruction , 0 , len ( path ) * 10 )
14121412 lval := c .genLocal ()
14131413
1414- for i := 0 ; i < len (path )- 1 ; i ++ {
1414+ for i := range len (path ) - 1 {
14151415 block = append (block , instruction.Block {Instrs : inner })
14161416 block = append (block , instruction.Call {Index : c .function (opaObject )})
14171417 block = append (block , instruction.SetLocal {Index : lval })
0 commit comments