bytestring 0.9.1.3 → 0.9.1.4
raw patch · 9 files changed
+75/−38 lines, 9 filesdep −sybdep ~base
Dependencies removed: syb
Dependency ranges changed: base
Files
- Data/ByteString.hs +14/−4
- Data/ByteString/Char8.hs +8/−1
- Data/ByteString/Internal.hs +11/−2
- Data/ByteString/Lazy.hs +13/−12
- Data/ByteString/Lazy/Char8.hs +6/−5
- Data/ByteString/Lazy/Internal.hs +12/−3
- Data/ByteString/Unsafe.hs +4/−0
- TODO +1/−0
- bytestring.cabal +6/−11
Data/ByteString.hs view
@@ -1,5 +1,9 @@ {-# LANGUAGE CPP #-}-{-# OPTIONS_GHC -XMagicHash -XUnboxedTuples #-}+#if __GLASGOW_HASKELL__ >= 608+{-# LANGUAGE MagicHash UnboxedTuples #-}+#else+{-# OPTIONS_GHC -fglasgow-exts #-}+#endif -- #prune @@ -220,13 +224,13 @@ import Data.Word (Word8) import Data.Maybe (isJust, listToMaybe) --- Control.Exception.bracket not available in yhc or nhc+-- Control.Exception.assert not available in yhc or nhc #ifndef __NHC__ import Control.Exception (finally, bracket, assert)-import qualified Control.Exception as Exception #else-import IO (bracket, finally)+import Control.Exception (bracket, finally) #endif+import qualified Control.Exception as Exception import Control.Monad (when) import Foreign.C.String (CString, CStringLen)@@ -960,12 +964,15 @@ {-# INLINE [1] break #-} #endif +#if __GLASGOW_HASKELL__ >= 606+-- This RULE LHS is not allowed by ghc-6.4 {-# RULES "ByteString specialise break (x==)" forall x. break ((==) x) = breakByte x "ByteString specialise break (==x)" forall x. break (==x) = breakByte x #-}+#endif -- INTERNAL: @@ -1013,12 +1020,15 @@ else go p (i+1) {-# INLINE spanByte #-} +#if __GLASGOW_HASKELL__ >= 606+-- This RULE LHS is not allowed by ghc-6.4 {-# RULES "ByteString specialise span (x==)" forall x. span ((==) x) = spanByte x "ByteString specialise span (==x)" forall x. span (==x) = spanByte x #-}+#endif -- | 'spanEnd' behaves like 'span' but from the end of the 'ByteString'. -- We have
Data/ByteString/Char8.hs view
@@ -1,5 +1,9 @@ {-# LANGUAGE CPP #-}-{-# OPTIONS_GHC -XMagicHash -XUnboxedTuples #-}+#if __GLASGOW_HASKELL__ >= 608+{-# LANGUAGE MagicHash UnboxedTuples #-}+#else+{-# OPTIONS_GHC -fglasgow-exts #-}+#endif -- #prune @@ -543,12 +547,15 @@ {-# INLINE [1] break #-} #endif +#if __GLASGOW_HASKELL__ >= 606+-- This RULE LHS is not allowed by ghc-6.4 {-# RULES "ByteString specialise break (x==)" forall x. break ((==) x) = breakChar x "ByteString specialise break (==x)" forall x. break (==x) = breakChar x #-}+#endif -- INTERNAL:
Data/ByteString/Internal.hs view
@@ -1,5 +1,9 @@ {-# LANGUAGE CPP, ForeignFunctionInterface #-}-{-# OPTIONS_GHC -XUnliftedFFITypes -XMagicHash -XUnboxedTuples -XDeriveDataTypeable #-}+#if __GLASGOW_HASKELL__ >= 608+{-# LANGUAGE UnliftedFFITypes MagicHash UnboxedTuples DeriveDataTypeable #-}+#else+{-# OPTIONS_GHC -fglasgow-exts #-}+#endif -- | -- Module : Data.ByteString.Internal -- License : BSD-style@@ -73,7 +77,12 @@ import Data.Word (Word8) #if defined(__GLASGOW_HASKELL__)-import Data.Generics (Data(..), Typeable(..))+import Data.Typeable (Typeable)+#if __GLASGOW_HASKELL__ >= 610+import Data.Data (Data)+#else+import Data.Generics (Data)+#endif import GHC.Ptr (Ptr(..)) import GHC.Base (realWorld#,unsafeChr) import GHC.IOBase (IO(IO), RawBuffer)
Data/ByteString/Lazy.hs view
@@ -204,6 +204,7 @@ ,getContents,getLine,putStr,putStrLn ,zip,zipWith,unzip,notElem) import qualified Data.List as L -- L for list/lazy+import qualified Data.ByteString as P (ByteString) -- type name only import qualified Data.ByteString as S -- S for strict (hmm...) import qualified Data.ByteString.Internal as S import qualified Data.ByteString.Unsafe as S@@ -304,11 +305,11 @@ --TODO: we can do better here by integrating the concat with the unpack -- | /O(c)/ Convert a list of strict 'ByteString' into a lazy 'ByteString'-fromChunks :: [S.ByteString] -> ByteString+fromChunks :: [P.ByteString] -> ByteString fromChunks cs = L.foldr chunk Empty cs -- | /O(n)/ Convert a lazy 'ByteString' into a list of strict 'ByteString'-toChunks :: ByteString -> [S.ByteString]+toChunks :: ByteString -> [P.ByteString] toChunks cs = foldrChunks (:) [] cs ------------------------------------------------------------------------@@ -446,7 +447,7 @@ intersperse _ Empty = Empty intersperse w (Chunk c cs) = Chunk (S.intersperse w c) (foldrChunks (Chunk . intersperse') Empty cs)- where intersperse' :: S.ByteString -> S.ByteString+ where intersperse' :: P.ByteString -> P.ByteString intersperse' (S.PS fp o l) = S.unsafeCreate (2*l) $ \p' -> withForeignPtr fp $ \p -> do poke p' w@@ -523,11 +524,11 @@ concatMap _ Empty = Empty concatMap f (Chunk c0 cs0) = to c0 cs0 where- go :: ByteString -> S.ByteString -> ByteString -> ByteString+ go :: ByteString -> P.ByteString -> ByteString -> ByteString go Empty c' cs' = to c' cs' go (Chunk c cs) c' cs' = Chunk c (go cs c' cs') - to :: S.ByteString -> ByteString -> ByteString+ to :: P.ByteString -> ByteString -> ByteString to c cs | S.null c = case cs of Empty -> Empty (Chunk c' cs') -> to c' cs'@@ -788,7 +789,7 @@ splitWith _ Empty = [] splitWith p (Chunk c0 cs0) = comb [] (S.splitWith p c0) cs0 - where comb :: [S.ByteString] -> [S.ByteString] -> ByteString -> [ByteString]+ where comb :: [P.ByteString] -> [P.ByteString] -> ByteString -> [ByteString] comb acc (s:[]) Empty = revChunks (s:acc) : [] comb acc (s:[]) (Chunk c cs) = comb (s:acc) (S.splitWith p c) cs comb acc (s:ss) cs = revChunks (s:acc) : comb [] ss cs@@ -815,7 +816,7 @@ split _ Empty = [] split w (Chunk c0 cs0) = comb [] (S.split w c0) cs0 - where comb :: [S.ByteString] -> [S.ByteString] -> ByteString -> [ByteString]+ where comb :: [P.ByteString] -> [P.ByteString] -> ByteString -> [ByteString] comb acc (s:[]) Empty = revChunks (s:acc) : [] comb acc (s:[]) (Chunk c cs) = comb (s:acc) (S.split w c) cs comb acc (s:ss) cs = revChunks (s:acc) : comb [] ss cs@@ -844,7 +845,7 @@ group Empty = [] group (Chunk c0 cs0) = group' [] (S.group c0) cs0 where - group' :: [S.ByteString] -> [S.ByteString] -> ByteString -> [ByteString]+ group' :: [P.ByteString] -> [P.ByteString] -> ByteString -> [ByteString] group' acc@(s':_) ss@(s:_) cs | S.unsafeHead s' /= S.unsafeHead s = revNonEmptyChunks acc : group' [] ss cs@@ -869,7 +870,7 @@ groupBy _ Empty = [] groupBy k (Chunk c0 cs0) = groupBy' [] 0 (S.groupBy k c0) cs0 where- groupBy' :: [S.ByteString] -> Word8 -> [S.ByteString] -> ByteString -> [ByteString]+ groupBy' :: [P.ByteString] -> Word8 -> [P.ByteString] -> ByteString -> [ByteString] groupBy' acc@(_:_) c ss@(s:_) cs | not (c `k` S.unsafeHead s) = revNonEmptyChunks acc : groupBy' [] 0 ss cs groupBy' acc _ (s:[]) Empty = revNonEmptyChunks (s : acc) : []@@ -1307,16 +1308,16 @@ -- reverse a list of non-empty chunks into a lazy ByteString-revNonEmptyChunks :: [S.ByteString] -> ByteString+revNonEmptyChunks :: [P.ByteString] -> ByteString revNonEmptyChunks cs = L.foldl' (flip Chunk) Empty cs -- reverse a list of possibly-empty chunks into a lazy ByteString-revChunks :: [S.ByteString] -> ByteString+revChunks :: [P.ByteString] -> ByteString revChunks cs = L.foldl' (flip chunk) Empty cs -- | 'findIndexOrEnd' is a variant of findIndex, that returns the length -- of the string if no element is found, rather than Nothing.-findIndexOrEnd :: (Word8 -> Bool) -> S.ByteString -> Int+findIndexOrEnd :: (Word8 -> Bool) -> P.ByteString -> Int findIndexOrEnd k (S.PS x s l) = S.inlinePerformIO $ withForeignPtr x $ \f -> go (f `plusPtr` s) 0 where STRICT2(go)
Data/ByteString/Lazy/Char8.hs view
@@ -187,6 +187,7 @@ -- Functions we need to wrap. import qualified Data.ByteString.Lazy as L+import qualified Data.ByteString as S (ByteString) -- typename only import qualified Data.ByteString as B import qualified Data.ByteString.Internal as B import qualified Data.ByteString.Unsafe as B@@ -665,7 +666,7 @@ -- the common special case where we have no existing chunks of -- the current line- loop0 :: B.ByteString -> ByteString -> [ByteString]+ loop0 :: S.ByteString -> ByteString -> [ByteString] loop0 c cs = case B.elemIndex (c2w '\n') c of Nothing -> case cs of@@ -682,7 +683,7 @@ -- the general case when we are building a list of chunks that are -- part of the same line- loop :: B.ByteString -> [B.ByteString] -> ByteString -> [ByteString]+ loop :: S.ByteString -> [S.ByteString] -> ByteString -> [ByteString] loop c line cs = case B.elemIndex (c2w '\n') c of Nothing ->@@ -762,7 +763,7 @@ _ -> loop False 0 0 x xs where loop :: Bool -> Int -> Int- -> B.ByteString -> ByteString -> Maybe (Int, ByteString)+ -> S.ByteString -> ByteString -> Maybe (Int, ByteString) {-# INLINE loop #-} STRICT5(loop) loop neg i n c cs@@ -809,7 +810,7 @@ | otherwise -> Nothing loop :: Int -> Int -> [Integer]- -> B.ByteString -> ByteString -> (Integer, ByteString)+ -> S.ByteString -> ByteString -> (Integer, ByteString) STRICT5(loop) loop d acc ns c cs | B.null c = case cs of@@ -859,5 +860,5 @@ -- Internal utilities -- reverse a list of possibly-empty chunks into a lazy ByteString-revChunks :: [B.ByteString] -> ByteString+revChunks :: [S.ByteString] -> ByteString revChunks cs = List.foldl' (flip chunk) Empty cs
Data/ByteString/Lazy/Internal.hs view
@@ -1,5 +1,9 @@ {-# LANGUAGE CPP #-}-{-# OPTIONS_GHC -XDeriveDataTypeable #-}+#if __GLASGOW_HASKELL__ >= 608+{-# LANGUAGE DeriveDataTypeable #-}+#else+{-# OPTIONS_GHC -fglasgow-exts #-}+#endif -- | -- Module : Data.ByteString.Lazy.Internal -- License : BSD-style@@ -34,10 +38,15 @@ import qualified Data.ByteString.Internal as S -import Foreign.Storable (sizeOf)+import Foreign.Storable (Storable(sizeOf)) #if defined(__GLASGOW_HASKELL__)-import Data.Generics (Data(..), Typeable(..))+import Data.Typeable (Typeable)+#if __GLASGOW_HASKELL__ >= 610+import Data.Data (Data)+#else+import Data.Generics (Data)+#endif #endif -- | A space-efficient representation of a Word8 vector, supporting many
Data/ByteString/Unsafe.hs view
@@ -1,5 +1,9 @@ {-# LANGUAGE CPP #-}+#if __GLASGOW_HASKELL__ >= 608+{-# LANGUAGE MagicHash #-}+#else {-# OPTIONS_GHC -XMagicHash #-}+#endif -- | -- Module : Data.ByteString.Unsafe -- License : BSD-style
TODO view
@@ -5,6 +5,7 @@ * stress testing * strictness testing * rewrite C code to Haskell+ * eliminate use of -fno-warn-orphans Todo items
bytestring.cabal view
@@ -1,5 +1,5 @@ Name: bytestring-Version: 0.9.1.3+Version: 0.9.1.4 Synopsis: Fast, packed, strict and lazy byte arrays with a list interface Description: A time and space-efficient implementation of byte vectors using@@ -16,7 +16,7 @@ License-file: LICENSE Category: Data Copyright: Copyright (c) Don Stewart 2005-2008,- (c) Duncan Coutts 2006-2007,+ (c) Duncan Coutts 2006-2008, (c) David Roundy 2003-2005. Author: Don Stewart, Duncan Coutts Maintainer: dons@galois.com, duncan@haskell.org@@ -27,17 +27,11 @@ Cabal-Version: >= 1.2 extra-source-files: README TODO -flag split-syb- library build-depends: base < 5- if flag(split-syb)- build-depends: base >= 4, syb- else- build-depends: base < 4 - if impl(ghc >= 6.9)- build-depends: ghc-prim+ if impl(ghc >= 6.10)+ build-depends: ghc-prim, base >= 4 exposed-modules: Data.ByteString Data.ByteString.Char8@@ -60,9 +54,10 @@ ghc-options: -Wall -fno-warn-orphans -O2 -funbox-strict-fields - -fdicts-cheap -fno-method-sharing -fmax-simplifier-iterations10+ if impl(ghc >= 6.6)+ ghc-options: -fdicts-cheap c-sources: cbits/fpstring.c include-dirs: include