@@ -160,18 +160,22 @@ hexadecimal :: Integral a => a -> Builder
160160{-# SPECIALIZE hexadecimal :: Word16 -> Builder #-}
161161{-# SPECIALIZE hexadecimal :: Word32 -> Builder #-}
162162{-# SPECIALIZE hexadecimal :: Word64 -> Builder #-}
163−{-# RULES "hexadecimal/Integer" hexadecimal = integer 16 :: Integer -> Builder #-}
163+{-# RULES "hexadecimal/Integer"
164+ hexadecimal = hexInteger :: Integer -> Builder #-}
164165hexadecimal i
165− | i < 0 = error msg
166+ | i < 0 = error hexErrMsg
166167 | otherwise = go i
167168 where
168169 go n | n < 16 = hexDigit n
169170 | otherwise = go (n `quot` 16) <> hexDigit (n `rem` 16)
170− msg = "Data.Text.Lazy.Builder.Int.hexadecimal: applied to negative number"
171171
172−digit :: Integral a => a -> Builder
173−digit n = singleton $! i2d (fromIntegral n)
174−{-# INLINE digit #-}
172+hexInteger :: Integer -> Builder
173+hexInteger i
174+ | i < 0 = error hexErrMsg
175+ | otherwise = integer 16 i
176+
177+hexErrMsg :: String
178+hexErrMsg = "Data.Text.Lazy.Builder.Int.hexadecimal: applied to negative number"
175179
176180hexDigit :: Integral a => a -> Builder
177181hexDigit n
@@ -244,7 +248,7 @@ integer base i
244248 pblock = loop maxDigits
245249 where
246250 loop !d !n
247− | d == 1 = digit n
248− | otherwise = loop (d-1) q <> digit r
251+ | d == 1 = hexDigit n
252+ | otherwise = loop (d-1) q <> hexDigit r
249253 where q = n `quotInt` base
250254 r = n `remInt` base