cli: optimize CosignersSeparator check in loops

No functional changes.
We have 2 exactly the same cycles,and in the 1st cycle we set
cosignersOffset to the right value. So we don't need to check for arg ==
 cmdargs.CosignersSeparator one more time.

Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
This commit is contained in:
Ekaterina Pavlova 2023-12-07 10:37:01 +03:00
parent 8bdbac3c5e
commit 44e21c9a8e

View file

@ -535,16 +535,16 @@ func multiTransferNEP17(ctx *cli.Context) error {
} }
var ( var (
recipients []transferTarget recipients []transferTarget
cosignersOffset = ctx.NArg() cosignersSepPos = ctx.NArg() // `--` position.
) )
for i := 0; i < ctx.NArg(); i++ { for i := 0; i < ctx.NArg(); i++ {
arg := ctx.Args().Get(i) arg := ctx.Args().Get(i)
if arg == cmdargs.CosignersSeparator { if arg == cmdargs.CosignersSeparator {
cosignersOffset = i + 1 cosignersSepPos = i
break break
} }
} }
cosigners, extErr := cmdargs.GetSignersFromContext(ctx, cosignersOffset) cosigners, extErr := cmdargs.GetSignersFromContext(ctx, cosignersSepPos+1)
if extErr != nil { if extErr != nil {
return extErr return extErr
} }
@ -558,11 +558,8 @@ func multiTransferNEP17(ctx *cli.Context) error {
} }
cache := make(map[string]*wallet.Token) cache := make(map[string]*wallet.Token)
for i := 0; i < cosignersOffset; i++ { for i := 0; i < cosignersSepPos; i++ {
arg := ctx.Args().Get(i) arg := ctx.Args().Get(i)
if arg == cmdargs.CosignersSeparator {
break
}
ss := strings.SplitN(arg, ":", 3) ss := strings.SplitN(arg, ":", 3)
if len(ss) != 3 { if len(ss) != 3 {
return cli.NewExitError("send format must be '<token>:<addr>:<amount>", 1) return cli.NewExitError("send format must be '<token>:<addr>:<amount>", 1)