[commit: bytestring] master: Fix a couple warnings (aaf8442)

Ian Lynagh igloo at earth.li
Fri Jan 11 16:35:18 CET 2013


Repository : ssh://darcs.haskell.org//srv/darcs/packages/bytestring

On branch  : master

http://hackage.haskell.org/trac/ghc/changeset/aaf84424aee2bac53b5121115b95ae47bcce17a2

>---------------------------------------------------------------

commit aaf84424aee2bac53b5121115b95ae47bcce17a2
Author: Duncan Coutts <duncan at community.haskell.org>
Date:   Tue Jan 8 19:54:07 2013 +0000

    Fix a couple warnings

>---------------------------------------------------------------

 Data/ByteString.hs |   15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/Data/ByteString.hs b/Data/ByteString.hs
index a166bbb..2da8cfe 100644
--- a/Data/ByteString.hs
+++ b/Data/ByteString.hs
@@ -234,7 +234,14 @@ import Control.Monad            (when)
 
 import Foreign.C.String         (CString, CStringLen)
 import Foreign.C.Types          (CSize)
-import Foreign.ForeignPtr
+#if MIN_VERSION_base(4,6,0)
+import Foreign.ForeignPtr       (ForeignPtr, newForeignPtr, withForeignPtr
+                                ,touchForeignPtr)
+import Foreign.ForeignPtr.Unsafe(unsafeForeignPtrToPtr)
+#else
+import Foreign.ForeignPtr       (ForeignPtr, newForeignPtr, withForeignPtr
+                                ,touchForeignPtr, unsafeForeignPtrToPtr)
+#endif
 import Foreign.Marshal.Alloc    (allocaBytes, mallocBytes, reallocBytes, finalizerFree)
 import Foreign.Marshal.Array    (allocaArray)
 import Foreign.Ptr
@@ -535,9 +542,9 @@ foldl f z (PS fp off len) =
 -- | 'foldl\'' is like 'foldl', but strict in the accumulator.
 --
 foldl' :: (a -> Word8 -> a) -> a -> ByteString -> a
-foldl' f v (PS x s l) =
-      inlinePerformIO $ withForeignPtr x $ \ptr ->
-        go v (ptr `plusPtr` s) (ptr `plusPtr` (s+l))
+foldl' f v (PS fp off len) =
+      inlinePerformIO $ withForeignPtr fp $ \p ->
+        go v (p `plusPtr` off) (p `plusPtr` (off+len))
     where
       -- tail recursive; traverses array left to right
       go !z !p !q | p == q    = return z





More information about the ghc-commits mailing list