convert serializeKey' to strict ByteString
The builder produces a lazy ByteString, and L.toStrict has to copy it, but needing to use the builder is no longer to common case; the serialization will normally be cached already as a strict ByteString, and this avoids keyFile' needing to use L.toStrict . serializeKey'
This commit is contained in:
parent
4536c93bb2
commit
e0c4ac99b5
5 changed files with 23 additions and 15 deletions
|
@ -27,12 +27,14 @@ module Utility.Hash (
|
|||
blake2b_512,
|
||||
#endif
|
||||
md5,
|
||||
md5s,
|
||||
prop_hashes_stable,
|
||||
Mac(..),
|
||||
calcMac,
|
||||
prop_mac_stable,
|
||||
) where
|
||||
|
||||
import qualified Data.ByteString as S
|
||||
import qualified Data.ByteString.Lazy as L
|
||||
import qualified Data.Text as T
|
||||
import qualified Data.Text.Encoding as T
|
||||
|
@ -112,6 +114,9 @@ blake2b_512 = hashlazy
|
|||
md5 :: L.ByteString -> Digest MD5
|
||||
md5 = hashlazy
|
||||
|
||||
md5s :: S.ByteString -> Digest MD5
|
||||
md5s = hash
|
||||
|
||||
{- Check that all the hashes continue to hash the same. -}
|
||||
prop_hashes_stable :: Bool
|
||||
prop_hashes_stable = all (\(hasher, result) -> hasher foo == result)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue