From 6c53241c370cfdc92c4c822af441d39a7fde5458 Mon Sep 17 00:00:00 2001 From: Hteev Oli Date: Tue, 29 Oct 2024 13:59:47 +0800 Subject: [PATCH] core, internal: use slices.Concat --- core/vm/eof.go | 10 +++------- internal/flags/helpers.go | 7 ++----- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/core/vm/eof.go b/core/vm/eof.go index fcced6ae751d..f5a7d89b2ad3 100644 --- a/core/vm/eof.go +++ b/core/vm/eof.go @@ -22,6 +22,7 @@ import ( "errors" "fmt" "io" + "slices" "strings" "github.com/ethereum/go-ethereum/params" @@ -136,14 +137,9 @@ func (c *Container) MarshalBinary() []byte { // Write section contents. for _, ty := range c.types { - b = append(b, []byte{ty.inputs, ty.outputs, byte(ty.maxStackHeight >> 8), byte(ty.maxStackHeight & 0x00ff)}...) - } - for _, code := range c.codeSections { - b = append(b, code...) - } - for _, section := range encodedContainer { - b = append(b, section...) + b = append(b, ty.inputs, ty.outputs, byte(ty.maxStackHeight >> 8), byte(ty.maxStackHeight & 0x00ff)) } + b = slices.Concat(b, slices.Concat(c.codeSections...), slices.Concat(encodedContainer...)) b = append(b, c.data...) return b diff --git a/internal/flags/helpers.go b/internal/flags/helpers.go index 32be3d11a7cd..fba74ec65ebb 100644 --- a/internal/flags/helpers.go +++ b/internal/flags/helpers.go @@ -20,6 +20,7 @@ import ( "fmt" "os" "regexp" + "slices" "sort" "strings" @@ -50,11 +51,7 @@ func NewApp(usage string) *cli.App { // Merge merges the given flag slices. func Merge(groups ...[]cli.Flag) []cli.Flag { - var ret []cli.Flag - for _, group := range groups { - ret = append(ret, group...) - } - return ret + return slices.Concat(groups...) } var migrationApplied = map[*cli.Command]struct{}{}