on master help sign in
Get rid of some compiler warnings.

--HG-- extra : convert_revision : 7ccf5f8270f0b55d4cb9e42da30b85447035bd8c

commit3cb61bf1f261a6456ab242a5788948f4089ffd7b authorBryan O'Sullivan <bos@serpentine.com> dateSat 23 May 2009, 01:58 (17 years ago) parent9c9d4cf
3 files changed+20−22
Data/Text/Encoding/Fusion.hs+5−6 Data/Text/Encoding/Fusion/Common.hs+1−1 Data/Text/Lazy/Encoding/Fusion.hs+14−15
Data/Text/Encoding/Fusion.hs+5−6
@@ -161,23 +161,22 @@ streamUtf32LE bs = Stream next 0 l
161161-- | /O(n)/ Convert a 'Stream' 'Word8' to a 'ByteString'.
162162unstream :: Stream Word8 -> ByteString
163163unstream (Stream next s0 len) = unsafePerformIO $ do
164− fp0 <- mallocByteString len
165− loop fp0 len 0 s0
164+ mallocByteString len >>= loop len 0 s0
166165 where
167− loop !fp !n !off !s = case next s of
166+ loop !n !off !s fp = case next s of
168167 Done -> trimUp fp n off
169− Skip s' -> loop fp n off s'
168+ Skip s' -> loop n off s' fp
170169 Yield x s'
171170 | off == n -> realloc fp n off s' x
172171 | otherwise -> do
173172 withForeignPtr fp $ \p -> pokeByteOff p off x
174− loop fp n (off+1) s'
173+ loop n (off+1) s' fp
175174 {-# NOINLINE realloc #-}
176175 realloc fp n off s x = do
177176 let n' = n+n
178177 fp' <- copy0 fp n n'
179178 withForeignPtr fp' $ \p -> pokeByteOff p off x
180− loop fp' n' (off+1) s
179+ loop n' (off+1) s fp'
181180 {-# NOINLINE trimUp #-}
182181 trimUp fp _ off = return $! PS fp 0 off
183182 copy0 :: ForeignPtr Word8 -> Int -> Int -> IO (ForeignPtr Word8)
Data/Text/Encoding/Fusion/Common.hs+1−1
@@ -27,7 +27,7 @@ module Data.Text.Encoding.Fusion.Common
2727 , restreamUtf32BE
2828 ) where
2929
30−import Data.Bits (shiftL, shiftR, (.&.))
30+import Data.Bits (shiftR, (.&.))
3131import Data.Char (ord)
3232import Data.Text.Fusion (Step(..), Stream(..))
3333import Data.Text.Fusion.Internal (M(..), S(..))
Data/Text/Lazy/Encoding/Fusion.hs+14−15
@@ -35,7 +35,7 @@ import qualified Data.ByteString.Unsafe as B
3535import Data.Text.Encoding.Fusion.Common
3636import Data.Text.Fusion (Step(..), Stream(..))
3737import Data.Text.Fusion.Internal (M(..), PairS(..), S(..))
38−import Data.Text.UnsafeChar (unsafeChr, unsafeChr8, unsafeChr32)
38+import Data.Text.UnsafeChar (unsafeChr8)
3939import Data.Word (Word8)
4040import qualified Data.Text.Encoding.Utf8 as U8
4141import System.IO.Unsafe (unsafePerformIO)
@@ -67,49 +67,48 @@ streamUtf8 bs0 = Stream next (bs0 :!: S N N N N :!: 0) unknownLength
6767 _ -> consume st
6868 where es = bs :!: S N N N N :!: i
6969 {-# INLINE consume #-}
70− consume (c@(Chunk bs rest) :!: s :!: i)
70+ consume (bs@(Chunk ps rest) :!: s :!: i)
7171 | i >= len = consume (rest :!: s :!: 0)
72− | otherwise = next (c :!: s' :!: i+1)
72+ | otherwise = next (bs :!: s' :!: i+1)
7373 where s' = case s of
7474 S N _ _ _ -> S x N N N
7575 S a N _ _ -> S a x N N
7676 S a b N _ -> S a b x N
7777 S a b c N -> S a b c x
7878 _ -> encodingError "streamUtf8" "UTF-8"
79− x = J (B.unsafeIndex bs i)
80− len = B.length bs
79+ x = J (B.unsafeIndex ps i)
80+ len = B.length ps
8181 consume (Empty :!: S N _ _ _ :!: _) = Done
8282 consume _ = encodingError "streamUtf8" "UTF-8"
8383{-# INLINE [0] streamUtf8 #-}
8484
8585-- | /O(n)/ Convert a 'Stream' 'Word8' to a lazy 'ByteString'.
8686unstreamChunks :: Int -> Stream Word8 -> ByteString
87−unstreamChunks chunkSize (Stream next s0 len) = chunk s0 len
88− where chunk s0 len = unsafePerformIO $ do
89− let safeLen = min (max len unknownLength) chunkSize
90− fp0 <- mallocByteString safeLen
91− loop fp0 safeLen 0 s0
87+unstreamChunks chunkSize (Stream next s0 len0) = chunk s0 len0
88+ where chunk s1 len1 = unsafePerformIO $ do
89+ let len = min (max len1 unknownLength) chunkSize
90+ mallocByteString len >>= loop len 0 s1
9291 where
93− loop !fp !n !off !s = case next s of
92+ loop !n !off !s fp = case next s of
9493 Done | off == 0 -> return Empty
9594 | otherwise -> do
9695 bs <- trimUp fp off
9796 return $! Chunk bs Empty
98− Skip s' -> loop fp n off s'
97+ Skip s' -> loop n off s' fp
9998 Yield x s'
10099 | off == chunkSize -> do
101100 bs <- trimUp fp off
102− return (Chunk bs (chunk s (len - B.length bs)))
101+ return (Chunk bs (chunk s (n - B.length bs)))
103102 | off == n -> realloc fp n off s' x
104103 | otherwise -> do
105104 withForeignPtr fp $ \p -> pokeByteOff p off x
106− loop fp n (off+1) s'
105+ loop n (off+1) s' fp
107106 {-# NOINLINE realloc #-}
108107 realloc fp n off s x = do
109108 let n' = min (n+n) chunkSize
110109 fp' <- copy0 fp n n'
111110 withForeignPtr fp' $ \p -> pokeByteOff p off x
112− loop fp' n' (off+1) s
111+ loop n' (off+1) s fp'
113112 {-# NOINLINE trimUp #-}
114113 trimUp fp off = return $! B.PS fp 0 off
115114 copy0 :: ForeignPtr Word8 -> Int -> Int -> IO (ForeignPtr Word8)