Skip to content

Commit dea6437

Browse files
author
Tommy TIAN
authoredAug 27, 2022
Remove useless error checks in default hash functions (#16)
Signed-off-by: txaty <[email protected]>
1 parent 3d0415b commit dea6437

File tree

2 files changed

+2
-80
lines changed

2 files changed

+2
-80
lines changed
 

‎default_hash.go

+2-8
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,7 @@ var sha256Digest = sha256.New()
3232
// It implements SHA256 hash function.
3333
func defaultHashFunc(data []byte) ([]byte, error) {
3434
defer sha256Digest.Reset()
35-
_, err := sha256Digest.Write(data)
36-
if err != nil {
37-
return nil, err
38-
}
35+
sha256Digest.Write(data)
3936
return sha256Digest.Sum(nil), nil
4037

4138
}
@@ -45,9 +42,6 @@ func defaultHashFunc(data []byte) ([]byte, error) {
4542
// When implementing hash functions for paralleled algorithms, please make sure it is concurrent safe.
4643
func defaultHashFuncParal(data []byte) ([]byte, error) {
4744
digest := sha256.New()
48-
_, err := digest.Write(data)
49-
if err != nil {
50-
return nil, err
51-
}
45+
digest.Write(data)
5246
return digest.Sum(nil), nil
5347
}

‎default_hash_test.go

-72
This file was deleted.

0 commit comments

Comments
 (0)