mirror of
https://github.com/QuilibriumNetwork/ceremonyclient.git
synced 2026-02-21 10:27:26 +08:00
* v2.1.0 [omit consensus and adjacent] - this commit will be amended with the full release after the file copy is complete * 2.1.0 main node rollup
33 lines
492 B
Go
33 lines
492 B
Go
// -*- go -*-
|
|
//
|
|
// Copyright (c) 2023 Markku Rossi
|
|
//
|
|
// All rights reserved.
|
|
//
|
|
|
|
package bytes
|
|
|
|
// Compare compares two byte slices lexicographically. The result is 0
|
|
// if a == b, -1 if a < b, and +1 if a > b.
|
|
func Compare(a, b []byte) int {
|
|
limit := len(a)
|
|
if len(b) < limit {
|
|
limit = len(b)
|
|
}
|
|
for i := 0; i < limit; i++ {
|
|
if a[i] < b[i] {
|
|
return -1
|
|
}
|
|
if a[i] > b[i] {
|
|
return 1
|
|
}
|
|
}
|
|
if len(a) < len(b) {
|
|
return -1
|
|
}
|
|
if len(a) > len(b) {
|
|
return 1
|
|
}
|
|
return 0
|
|
}
|