From da52607d41f49ef7f493f0a5dc456f1d78f360aa Mon Sep 17 00:00:00 2001 From: Vincent Hanquez Date: Sun, 19 Apr 2015 06:16:31 +0100 Subject: [PATCH] [internal] make some binding stricter --- Crypto/Internal/CompatPrim.hs | 9 +++++---- Crypto/Internal/WordArray.hs | 6 +++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Crypto/Internal/CompatPrim.hs b/Crypto/Internal/CompatPrim.hs index 4e8db8d..3db9828 100644 --- a/Crypto/Internal/CompatPrim.hs +++ b/Crypto/Internal/CompatPrim.hs @@ -12,6 +12,7 @@ -- to write compat code for primitives -- {-# LANGUAGE CPP #-} +{-# LANGUAGE BangPatterns #-} {-# LANGUAGE MagicHash #-} module Crypto.Internal.CompatPrim ( be32Prim @@ -33,10 +34,10 @@ byteswap32Prim :: Word# -> Word# byteswap32Prim w = byteSwap32# w #else byteswap32Prim w = - let a = uncheckedShiftL# w 24# - b = and# (uncheckedShiftL# w 8#) 0x00ff0000## - c = and# (uncheckedShiftRL# w 8#) 0x0000ff00## - d = and# (uncheckedShiftRL# w 24#) 0x000000ff## + let !a = uncheckedShiftL# w 24# + !b = and# (uncheckedShiftL# w 8#) 0x00ff0000## + !c = and# (uncheckedShiftRL# w 8#) 0x0000ff00## + !d = and# (uncheckedShiftRL# w 24#) 0x000000ff## in or# a (or# b (or# c d)) #endif diff --git a/Crypto/Internal/WordArray.hs b/Crypto/Internal/WordArray.hs index 52d3896..4211b36 100644 --- a/Crypto/Internal/WordArray.hs +++ b/Crypto/Internal/WordArray.hs @@ -76,7 +76,7 @@ array64 (I# n) l = unsafeDoIO $ IO $ \s -> loop i st mb ((W64# x):xs) | booleanPrim (i ==# n) = freezeArray mb st | otherwise = - let st' = writeWord64Array# mb i x st + let !st' = writeWord64Array# mb i x st in loop (i +# 1#) st' mb xs freezeArray mb st = case unsafeFreezeByteArray# mb st of @@ -92,7 +92,7 @@ mutableArray32 (I# n) l = IO $ \s -> loop i st mb ((W32# x):xs) | booleanPrim (i ==# n) = (# st, MutableArray32 mb #) | otherwise = - let st' = writeWord32Array# mb i x st + let !st' = writeWord32Array# mb i x st in loop (i +# 1#) st' mb xs mutableArray32FromAddrBE :: Int -> Addr# -> IO MutableArray32 @@ -103,7 +103,7 @@ mutableArray32FromAddrBE (I# n) a = IO $ \s -> loop i st mb | booleanPrim (i ==# n) = (# st, MutableArray32 mb #) | otherwise = - let st' = writeWord32Array# mb i (be32Prim (indexWord32OffAddr# a i)) st + let !st' = writeWord32Array# mb i (be32Prim (indexWord32OffAddr# a i)) st in loop (i +# 1#) st' mb mutableArray32Freeze :: MutableArray32 -> IO Array32