mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2025-05-05 23:55:11 +00:00
*: use cmp.Or where appropriate
It's slightly less efficient (all comparisons are always made), but for strings/ints it's negligible performance difference, while the code looks a tiny bit better. Signed-off-by: Roman Khimov <roman@nspcc.ru>
This commit is contained in:
parent
357bc76882
commit
a50723ff72
3 changed files with 12 additions and 15 deletions
|
@ -200,11 +200,10 @@ func queryCandidates(ctx *cli.Context) error {
|
|||
if !a.Active && b.Active {
|
||||
return -1
|
||||
}
|
||||
res := cmp.Compare(a.Votes, b.Votes)
|
||||
if res != 0 {
|
||||
return res
|
||||
}
|
||||
return a.PublicKey.Cmp(&b.PublicKey)
|
||||
return cmp.Or(
|
||||
cmp.Compare(a.Votes, b.Votes),
|
||||
a.PublicKey.Cmp(&b.PublicKey),
|
||||
)
|
||||
})
|
||||
var res []byte
|
||||
res = fmt.Appendf(res, "Key\tVotes\tCommittee\tConsensus\n")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue