mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2025-01-10 15:54:05 +00:00
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:
parent
8bdbac3c5e
commit
44e21c9a8e
1 changed files with 4 additions and 7 deletions
|
@ -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)
|
||||||
|
|
Loading…
Reference in a new issue