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:
|
case Item:
|
||||||
return val
|
return val
|
||||||
case []int:
|
case []int:
|
||||||
var a []Item
|
var res = make([]Item, len(val))
|
||||||
for _, i := range val {
|
for i := range val {
|
||||||
a = append(a, Make(i))
|
res[i] = Make(val[i])
|
||||||
}
|
}
|
||||||
return Make(a)
|
return Make(res)
|
||||||
case []string:
|
case []string:
|
||||||
var a []Item
|
var res = make([]Item, len(val))
|
||||||
for _, i := range val {
|
for i := range val {
|
||||||
a = append(a, Make(i))
|
res[i] = Make(val[i])
|
||||||
}
|
}
|
||||||
return Make(a)
|
return Make(res)
|
||||||
case []any:
|
case []any:
|
||||||
res := make([]Item, len(val))
|
res := make([]Item, len(val))
|
||||||
for i := range val {
|
for i := range val {
|
||||||
|
|
Loading…
Reference in a new issue