vm: microoptimize new estack creation
Subslice won't reach element -1, but it can reuse the same buffer space more effectively.
This commit is contained in:
parent
10110d4e70
commit
3d4076ca36
2 changed files with 9 additions and 1 deletions
|
@ -132,6 +132,14 @@ func newStack(n string, refc *refCounter) *Stack {
|
|||
initStack(s, n, refc)
|
||||
return s
|
||||
}
|
||||
|
||||
func subStack(old *Stack) *Stack {
|
||||
s := new(Stack)
|
||||
*s = *old
|
||||
s.elems = s.elems[len(s.elems):]
|
||||
return s
|
||||
}
|
||||
|
||||
func initStack(s *Stack, n string, refc *refCounter) {
|
||||
s.name = n
|
||||
s.refs = refc
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue