diff --git a/CHANGELOG b/CHANGELOG
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,5 +1,8 @@
 # Changelog
 
+- 0.1.2 (2025-01-07)
+  * Makes a minor optimisation to bytestring handling.
+
 - 0.1.1 (2024-10-13)
   * Adds an INLINE pragma to an internal step function.
   * 'hmac' no longer calls 'hmac_lazy', which has no practical effect
diff --git a/lib/Crypto/Hash/SHA512.hs b/lib/Crypto/Hash/SHA512.hs
--- a/lib/Crypto/Hash/SHA512.hs
+++ b/lib/Crypto/Hash/SHA512.hs
@@ -83,14 +83,14 @@
 splitAt128 :: BL.ByteString -> SLPair
 splitAt128 = splitAt' (128 :: Int) where
   splitAt' _ BLI.Empty        = SLPair mempty BLI.Empty
-  splitAt' n (BLI.Chunk c cs) =
-    if    n < BS.length c
+  splitAt' n (BLI.Chunk c@(BI.PS _ _ l) cs) =
+    if    n < l
     then
       -- n < BS.length c, so unsafe_splitAt is safe
       let !(SSPair c0 c1) = unsafe_splitAt n c
       in  SLPair c0 (BLI.Chunk c1 cs)
     else
-      let SLPair cs' cs'' = splitAt' (n - BS.length c) cs
+      let SLPair cs' cs'' = splitAt' (n - l) cs
       in  SLPair (c <> cs') cs''
 
 -- variant of Data.ByteString.splitAt that behaves like an incremental
@@ -116,10 +116,8 @@
 
 -- RFC 6234 4.1 (strict)
 pad :: BS.ByteString -> BS.ByteString
-pad m = BL.toStrict . BSB.toLazyByteString $ padded where
-  l = fi (BS.length m)
+pad m@(BI.PS _ _ (fi -> l)) = BL.toStrict . BSB.toLazyByteString $ padded where
   padded = BSB.byteString m <> fill (sol l) (BSB.word8 0x80)
-
   fill j !acc
     | j == 0 = acc <> BSB.word64BE 0x00 <> BSB.word64BE (l * 8)
     | otherwise = fill (pred j) (acc <> BSB.word8 0x00)
@@ -513,7 +511,7 @@
   :: BS.ByteString -- ^ key
   -> BS.ByteString -- ^ text
   -> BS.ByteString
-hmac mk text =
+hmac mk@(BI.PS _ _ l) text =
     let step1 = k <> BS.replicate (128 - lk) 0x00
         step2 = BS.map (B.xor 0x36) step1
         step3 = step2 <> text
@@ -522,11 +520,9 @@
         step6 = step5 <> step4
     in  hash step6
   where
-    !(KeyAndLen k lk) =
-      let l = BS.length mk
-      in  if   l > 128
-          then KeyAndLen (hash mk) 64
-          else KeyAndLen mk l
+    !(KeyAndLen k lk)
+      | l > 128   = KeyAndLen (hash mk) 64
+      | otherwise = KeyAndLen mk l
 
 -- | Produce a message authentication code for a lazy bytestring, based
 --   on the provided (strict, bytestring) key, via SHA-512.
@@ -542,7 +538,7 @@
   :: BS.ByteString -- ^ key
   -> BL.ByteString -- ^ text
   -> BS.ByteString
-hmac_lazy mk text =
+hmac_lazy mk@(BI.PS _ _ l) text =
     let step1 = k <> BS.replicate (128 - lk) 0x00
         step2 = BS.map (B.xor 0x36) step1
         step3 = BL.fromStrict step2 <> text
@@ -551,9 +547,7 @@
         step6 = step5 <> step4
     in  hash step6
   where
-    !(KeyAndLen k lk) =
-      let l = BS.length mk
-      in  if   l > 128
-          then KeyAndLen (hash mk) 64
-          else KeyAndLen mk l
+    !(KeyAndLen k lk)
+      | l > 128   = KeyAndLen (hash mk) 64
+      | otherwise = KeyAndLen mk l
 
diff --git a/ppad-sha512.cabal b/ppad-sha512.cabal
--- a/ppad-sha512.cabal
+++ b/ppad-sha512.cabal
@@ -1,6 +1,6 @@
 cabal-version:      3.0
 name:               ppad-sha512
-version:            0.1.1
+version:            0.1.2
 synopsis:           The SHA-512 and HMAC-SHA512 algorithms
 license:            MIT
 license-file:       LICENSE
