asm: reuses the slice on SetBranchTargetOnNextNodes (#1303)

Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
This commit is contained in:
Takeshi Yoneda
2023-03-28 20:20:50 -07:00
committed by GitHub
parent 2fc1fa9d79
commit 376292fe53
2 changed files with 4 additions and 2 deletions

View File

@@ -310,7 +310,8 @@ func (a *AssemblerImpl) addNode(node *nodeImpl) {
origin := o.(*nodeImpl)
origin.jumpTarget = node
}
a.SetBranchTargetOnNextNodes = nil
// Reuse the underlying slice to avoid re-allocations.
a.SetBranchTargetOnNextNodes = a.SetBranchTargetOnNextNodes[:0]
}
// EncodeNode encodes the given node into writer.

View File

@@ -308,7 +308,8 @@ func (a *AssemblerImpl) addNode(node *nodeImpl) {
origin := o.(*nodeImpl)
origin.jumpTarget = node
}
a.SetBranchTargetOnNextNodes = nil
// Reuse the underlying slice to avoid re-allocations.
a.SetBranchTargetOnNextNodes = a.SetBranchTargetOnNextNodes[:0]
}
// Assemble implements asm.AssemblerBase