stringsearch 0.3.0 → 0.3.1
raw patch · 7 files changed
+47/−26 lines, 7 files
Files
- CHANGES +3/−0
- Data/ByteString/Lazy/Search.hs +2/−0
- Data/ByteString/Lazy/Search/DFA.hs +17/−13
- Data/ByteString/Search.hs +2/−0
- Data/ByteString/Search/DFA.hs +2/−0
- Data/ByteString/Search/Internal/BoyerMoore.hs +20/−12
- stringsearch.cabal +1/−1
CHANGES view
@@ -1,3 +1,6 @@+0.3.1:+- fix spaceleak in split due to pairs holding on to first component+- fix docs for splitKeepFront 0.3.0: - improved performance of old KMP searching functions (minor) - changed behaviour for empty patterns
Data/ByteString/Lazy/Search.hs view
@@ -312,6 +312,8 @@ -- | @splitKeepFront@ is like 'splitKeepEnd', except that @target@ is split -- before each occurrence of @pattern@ and hence all fragments -- with the possible exception of the first begin with @pattern@.+-- No fragment contains more than one non-overlapping occurrence+-- of @pattern@. {-# INLINE splitKeepFront #-} splitKeepFront :: S.ByteString -- ^ Strict pattern to split on -> L.ByteString -- ^ Lazy string to split
Data/ByteString/Lazy/Search/DFA.hs view
@@ -252,8 +252,9 @@ splitter' strs | null strs = [[]] | otherwise =- let (pre, mtch) = breaker strs- in pre : case mtch of+ case breaker strs of+ (pre, mtch) ->+ pre : case mtch of [] -> [] _ -> splitter' (ldrop patLen mtch) @@ -278,12 +279,14 @@ breaker = lazyBreaker False pat splitter [] = [] splitter strs =- let (pre, mtch) = breaker strs- in pre : splitter mtch+ case breaker strs of+ (pre, mtch) -> pre : splitter mtch -- | @splitKeepFront@ is like 'splitKeepEnd', except that @target@ is split -- before each occurrence of @pattern@ and hence all fragments -- with the possible exception of the first begin with @pattern@.+-- No fragment contains more than one non-overlapping occurrence+-- of @pattern@. splitKeepFront :: S.ByteString -- ^ Strict pattern to split on -> L.ByteString -- ^ Lazy string to split -> [L.ByteString] -- ^ Fragments of string@@ -298,15 +301,16 @@ other -> other splitter' [] = [] splitter' strs =- let (pre, mtch) = breaker strs- in pre : case mtch of- [] -> []- _ -> case lsplit patLen mtch of- (pt, rst) ->- if null rst- then [pt]- else let (h : t) = splitter' rst- in (pt ++ h) : t+ case breaker strs of+ (pre, mtch) ->+ pre : case mtch of+ [] -> []+ _ -> case lsplit patLen mtch of+ (pt, rst) ->+ if null rst+ then [pt]+ else let (h : t) = splitter' rst+ in (pt ++ h) : t ------------------------------------------------------------------------------ -- Searching Function --
Data/ByteString/Search.hs view
@@ -245,6 +245,8 @@ -- | @splitKeepFront@ is like 'splitKeepEnd', except that @target@ is split -- before each occurrence of @pattern@ and hence all fragments -- with the possible exception of the first begin with @pattern@.+-- No fragment contains more than one non-overlapping occurrence+-- of @pattern@. {-# INLINE splitKeepFront #-} splitKeepFront :: S.ByteString -- ^ Pattern to split on -> S.ByteString -- ^ String to split
Data/ByteString/Search/DFA.hs view
@@ -260,6 +260,8 @@ -- | @splitKeepFront@ is like 'splitKeepEnd', except that @target@ is split -- before each occurrence of @pattern@ and hence all fragments -- with the possible exception of the first begin with @pattern@.+-- No fragment contains more than one non-overlapping occurrence+-- of @pattern@. splitKeepFront :: S.ByteString -- ^ Pattern to split on -> S.ByteString -- ^ String to split -> [S.ByteString] -- ^ Fragments of string
Data/ByteString/Search/Internal/BoyerMoore.hs view
@@ -964,8 +964,9 @@ other -> other splitter [] = [] splitter strs =- let (pre, mtch) = breaker strs- in pre : case mtch of+ case breaker strs of+ (pre, mtch) ->+ pre : case mtch of [] -> [] _ -> case lsplit patLen mtch of (pt, rst) ->@@ -982,12 +983,13 @@ breaker = lazyBreak pat splitter [] = [] splitter strs =- let (pre, mtch) = breaker strs- (h : t) = if null mtch- then [[]]- else case lsplit patLen mtch of- (pt, rst) -> pt : splitter rst- in (pre ++ h) : t+ case breaker strs of+ (pre, mtch) ->+ let (h : t) = if null mtch+ then [[]]+ else case lsplit patLen mtch of+ (pt, rst) -> pt : splitter rst+ in (pre ++ h) : t lazySplitDrop :: S.ByteString -> [S.ByteString] -> [[S.ByteString]] lazySplitDrop pat = splitter@@ -997,10 +999,11 @@ splitter [] = [] splitter strs = splitter' strs splitter' [] = [[]]- splitter' strs = let (pre, mtch) = breaker strs- in pre : case mtch of- [] -> []- _ -> splitter' (ldrop patLen mtch)+ splitter' strs = case breaker strs of+ (pre,mtch) ->+ pre : case mtch of+ [] -> []+ _ -> splitter' (ldrop patLen mtch) ------------------------------------------------------------------------------ -- Replacing Functions --@@ -1068,6 +1071,11 @@ -- -- Sigh, it is significantly faster. 10 - 25 %. -- I could live with the 10, but 25 is too much.+--+-- Hmm, maybe an implementation via+-- replace pat sub = L.intercalate sub . split pat+-- would be competitive now.+-- TODO: test speed and space usage. -- -- replacing loop for lazy ByteStrings as list of chunks, -- called only for non-empty patterns
stringsearch.cabal view
@@ -7,7 +7,7 @@ -- The package version. See the Haskell package versioning policy -- (http://www.haskell.org/haskellwiki/Package_versioning_policy) for -- standards guiding when and how versions should be incremented.-Version: 0.3.0+Version: 0.3.1 -- A short (one-line) description of the package. Synopsis: Fast searching, splitting and replacing of ByteStrings