Merge pull request #13 from nspcc-dev/fix/cpuid
Detect CPU features in Sum()
This commit is contained in:
commit
06362477ed
1 changed files with 13 additions and 3 deletions
10
tz/hash.go
10
tz/hash.go
|
@ -70,9 +70,19 @@ func New() hash.Hash {
|
||||||
|
|
||||||
// Sum returns Tillich-Zémor checksum of data.
|
// Sum returns Tillich-Zémor checksum of data.
|
||||||
func Sum(data []byte) [hashSize]byte {
|
func Sum(data []byte) [hashSize]byte {
|
||||||
|
if hasAVX2 {
|
||||||
d := newAVX2Inline()
|
d := newAVX2Inline()
|
||||||
_, _ = d.Write(data) // no errors
|
_, _ = d.Write(data) // no errors
|
||||||
return d.checkSum()
|
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.
|
// Concat performs combining of hashes based on homomorphic property.
|
||||||
|
|
Loading…
Reference in a new issue