interop: simplify code with slices.Insert

It's not performance-critical for sure.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
This commit is contained in:
Roman Khimov 2024-08-26 20:26:43 +03:00
parent a0553f740d
commit 6581bd47fc

View file

@ -6,6 +6,7 @@ import (
"errors"
"fmt"
"sort"
"slices"
"strings"
"github.com/nspcc-dev/neo-go/pkg/config"
@ -368,9 +369,7 @@ func (c *ContractMD) AddMethod(md *MethodAndPrice, desc *manifest.Method) {
}
return len(md.Parameters) > len(desc.Parameters)
})
c.methods = append(c.methods, MethodAndPrice{})
copy(c.methods[index+1:], c.methods[index:])
c.methods[index] = *md
c.methods = slices.Insert(c.methods, index, *md)
if md.ActiveFrom != nil {
c.ActiveHFs[*md.ActiveFrom] = struct{}{}