bytestring 0.9.1.0 → 0.9.1.1
raw patch · 4 files changed
+49/−22 lines, 4 filesdep +ghc-prim
Dependencies added: ghc-prim
Files
- Data/ByteString.hs +8/−2
- Data/ByteString/Lazy/Char8.hs +23/−11
- TODO +1/−2
- bytestring.cabal +17/−7
Data/ByteString.hs view
@@ -887,7 +887,7 @@ -- -- The following equation relates 'unfoldrN' and 'unfoldr': ----- > unfoldrN n f s == take n (unfoldr f s)+-- > snd (unfoldrN n f s) == take n (unfoldr f s) -- unfoldrN :: Int -> (a -> Maybe (Word8, a)) -> a -> (ByteString, Maybe a) unfoldrN i f x0@@ -1828,7 +1828,13 @@ -- | Read a 'ByteString' directly from the specified 'Handle'. This -- is far more efficient than reading the characters into a 'String' -- and then using 'pack'. First argument is the Handle to read from, --- and the second is the number of bytes to read.+-- and the second is the number of bytes to read. It returns the bytes+-- read, up to n, or EOF.+--+-- 'hGet' is implemented in terms of 'hGetBuf'.+--+-- If the handle is a pipe or socket, and the writing end+-- is closed, 'hGet' will behave as if EOF was reached. -- hGet :: Handle -> Int -> IO ByteString hGet _ 0 = return empty
Data/ByteString/Lazy/Char8.hs view
@@ -746,15 +746,25 @@ -- there is no integer at the beginning of the string, it returns -- Nothing, otherwise it just returns the int read, and the rest of the -- string.++{-+-- Faster:++data MaybeS = NothingS+ | JustS {-# UNPACK #-} !Int {-# UNPACK #-} !ByteString+-}+ readInt :: ByteString -> Maybe (Int, ByteString)+{-# INLINE readInt #-} readInt Empty = Nothing-readInt (Chunk x xs) =- case w2c (B.unsafeHead x) of- '-' -> loop True 0 0 (B.unsafeTail x) xs- '+' -> loop False 0 0 (B.unsafeTail x) xs- _ -> loop False 0 0 x xs+readInt (Chunk x xs) = case w2c (B.unsafeHead x) of+ '-' -> loop True 0 0 (B.unsafeTail x) xs+ '+' -> loop False 0 0 (B.unsafeTail x) xs+ _ -> loop False 0 0 x xs - where loop :: Bool -> Int -> Int -> B.ByteString -> ByteString -> Maybe (Int, ByteString)+ where loop :: Bool -> Int -> Int+ -> B.ByteString -> ByteString -> Maybe (Int, ByteString)+ {-# INLINE loop #-} STRICT5(loop) loop neg i n c cs | B.null c = case cs of@@ -768,11 +778,13 @@ (B.unsafeTail c) cs | otherwise -> end neg i n c cs - end _ 0 _ _ _ = Nothing- end neg _ n c cs = let n' | neg = negate n- | otherwise = n- c' = chunk c cs- in n' `seq` c' `seq` Just $! (n', c')+ {-# INLINE end #-}+ end _ 0 _ _ _ = Nothing+ end neg _ n c cs = e `seq` e+ where n' = if neg then negate n else n+ c' = chunk c cs+ e = n' `seq` c' `seq` Just $! (n',c')+ -- in n' `seq` c' `seq` JustS n' c' -- | readInteger reads an Integer from the beginning of the ByteString. If
TODO view
@@ -1,11 +1,10 @@ TODO: * back port streams fusion code.- * close bug in Lazy.lines * show instance for LPS- * ensure memchr / (== c) rules either always work, or we can back door them * stress testing * strictness testing+ * rewrite C code to Haskell Todo items
bytestring.cabal view
@@ -1,5 +1,5 @@ Name: bytestring-Version: 0.9.1.0+Version: 0.9.1.1 Synopsis: Fast, packed, strict and lazy byte arrays with a list interface Description: .@@ -30,6 +30,9 @@ library build-depends: base+ if impl(ghc > 6.8.2)+ build-depends: ghc-prim+ exposed-modules: Data.ByteString Data.ByteString.Char8 Data.ByteString.Unsafe@@ -42,13 +45,19 @@ extensions: CPP, ForeignFunctionInterface if impl(ghc)- extensions: UnliftedFFITypes, MagicHash, UnboxedTuples, DeriveDataTypeable+ extensions: UnliftedFFITypes,+ MagicHash,+ UnboxedTuples,+ DeriveDataTypeable - ghc-options: -fglasgow-exts- -Wall -fno-warn-orphans- -O2 -funbox-strict-fields - -fdicts-cheap -fno-method-sharing- -fmax-simplifier-iterations10 -fcpr-off+ ghc-options: -fglasgow-exts+ -Wall -fno-warn-orphans+ -O2+ -funbox-strict-fields + -fdicts-cheap+ -fno-method-sharing+ -fmax-simplifier-iterations10+ -- -- -fglasgow-exts needed for local rewrite rules: --@@ -61,3 +70,4 @@ nhc98-options: -K4M -K3M if impl(ghc <= 6.4.2) cc-options: -DSLOW_FOREIGN_PTR+