Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Make an optimization for x86 (if people use the flag they get ~ 4x sp…

…eedup)

Ignore-this: c743704018c0690520e3854c2a5e709b

darcs-hash:20100907030404-cef97-d40286e20f4aaced6a7f410090c5fa22b2aea7f1.gz
  • Loading branch information...
commit 5a0750effbaff8c98fc7b2a10c004d2628b6afde 1 parent 3c21db2
@TomMD authored
Showing with 6 additions and 4 deletions.
  1. +6 −4 Data/Digest/Pure/MD5.hs
View
10 Data/Digest/Pure/MD5.hs
@@ -1,4 +1,4 @@
-{-# LANGUAGE BangPatterns, ForeignFunctionInterface, MultiParamTypeClasses #-}
+{-# LANGUAGE BangPatterns, ForeignFunctionInterface, MultiParamTypeClasses, CPP #-}
-----------------------------------------------------------------------------
--
-- Module : Data.Digest.Pure.MD5
@@ -237,12 +237,14 @@ applyMD5Rounds par@(MD5Par a b c d) w = {-# SCC "applyMD5Rounds" #-}
{-# INLINE (!!) #-}
{-# INLINE applyMD5Rounds #-}
+#ifdef LittleEndian
+getNthWord n b = inlinePerformIO (unsafeUseAsCString b (flip peekElemOff n . castPtr))
+#else
getNthWord :: Int -> B.ByteString -> Word32
-getNthWord n = right . G.runGet (do
- G.uncheckedSkip (n * sizeOf (undefined :: Word32))
- G.getWord32le)
+getNthWord n = right . G.runGet G.getWord32le . B.drop (n * sizeOf (undefined :: Word32))
where
right x = case x of Right y -> y
+#endif
{-# INLINE getNthWord #-}
infix 9 .<.
Please sign in to comment.
Something went wrong with that request. Please try again.