*: 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:
Roman Khimov 2024-08-30 15:07:52 +03:00
parent 357bc76882
commit a50723ff72
3 changed files with 12 additions and 15 deletions

View file

@ -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")