Skip to content

Commit

Permalink
compare whole bytes without loop
Browse files Browse the repository at this point in the history
  • Loading branch information
jannotti committed Dec 18, 2024
1 parent 475cd5e commit 9cf40d0
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions ledger/apply/challenge.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package apply

import (
"bytes"
"math/bits"

"github.com/algorand/go-algorand/config"
Expand Down Expand Up @@ -97,12 +98,11 @@ func bitsMatch(a, b []byte, n int) bool {
return false
}

// Compare entire bytes when n is bigger than 8
for i := 0; i < n/8; i++ {
if a[i] != b[i] {
return false
}
// Compare entire bytes when we care about enough bits
if !bytes.Equal(a[:n/8], b[:n/8]) {
return false
}

remaining := n % 8
if remaining == 0 {
return true
Expand Down

0 comments on commit 9cf40d0

Please sign in to comment.