mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2025-01-09 11:19:06 +00:00
stackitem: microoptimize memory management of Make()
Preallocate as much as needed. Signed-off-by: Roman Khimov <roman@nspcc.ru>
This commit is contained in:
parent
e8a86e617b
commit
93ecd61079
1 changed files with 8 additions and 8 deletions
|
@ -124,17 +124,17 @@ func Make(v any) Item {
|
|||
case Item:
|
||||
return val
|
||||
case []int:
|
||||
var a []Item
|
||||
for _, i := range val {
|
||||
a = append(a, Make(i))
|
||||
var res = make([]Item, len(val))
|
||||
for i := range val {
|
||||
res[i] = Make(val[i])
|
||||
}
|
||||
return Make(a)
|
||||
return Make(res)
|
||||
case []string:
|
||||
var a []Item
|
||||
for _, i := range val {
|
||||
a = append(a, Make(i))
|
||||
var res = make([]Item, len(val))
|
||||
for i := range val {
|
||||
res[i] = Make(val[i])
|
||||
}
|
||||
return Make(a)
|
||||
return Make(res)
|
||||
case []any:
|
||||
res := make([]Item, len(val))
|
||||
for i := range val {
|
||||
|
|
Loading…
Reference in a new issue