lib: Use bytes.Equal instead of bytes.Compare where possible

This commit is contained in:
Jakob Borg
2016-03-31 15:12:46 +00:00
committed by Audrius Butkevicius
parent b6f32b6e45
commit f5f0e46016
8 changed files with 21 additions and 21 deletions

View File

@@ -107,7 +107,7 @@ func BlockDiff(src, tgt []protocol.BlockInfo) (have, need []protocol.BlockInfo)
}
for i := range tgt {
if i >= len(src) || bytes.Compare(tgt[i].Hash, src[i].Hash) != 0 {
if i >= len(src) || !bytes.Equal(tgt[i].Hash, src[i].Hash) {
// Copy differing block
need = append(need, tgt[i])
} else {
@@ -132,7 +132,7 @@ func Verify(r io.Reader, blocksize int, blocks []protocol.BlockInfo) error {
hash := hf.Sum(nil)
hf.Reset()
if bytes.Compare(hash, block.Hash) != 0 {
if !bytes.Equal(hash, block.Hash) {
return fmt.Errorf("hash mismatch %x != %x for block %d", hash, block.Hash, i)
}
}