Detect CPU features in Sum()

This commit is contained in:
Evgenii Stratonikov 2019-10-04 17:57:53 +03:00
parent 083d0ff054
commit 38df9b2c63

View file

@ -70,9 +70,19 @@ func New() hash.Hash {
// Sum returns Tillich-Zémor checksum of data.
func Sum(data []byte) [hashSize]byte {
if hasAVX2 {
d := newAVX2Inline()
_, _ = d.Write(data) // no errors
return d.checkSum()
} else if hasAVX {
d := newAVX()
_, _ = d.Write(data) // no errors
return d.checkSum()
} else {
d := newPure()
_, _ = d.Write(data) // no errors
return d.checkSum()
}
}
// Concat performs combining of hashes based on homomorphic property.