
29 Apr
2010
29 Apr
'10
10:53 a.m.
On Thu, Apr 29, 2010 at 10:54:09AM +0200, Ketil Malde wrote:
Anyway - it occurs to me that this can fairly simply be sped up by parallelizing: chunk the input, complement chunks in parallel, and reverse. Any takers?
Do you mean, something like this? import Data.ByteString.Char8 as S import Data.ByteString.Lazy.Char8 as L import Data.ByteString.Lazy.Internal as LI map' :: (Char -> Char) -> L.ByteString -> L.ByteString map' f = go where go LI.Empty = LI.Empty go (LI.Chunk x xs) = let fx = S.map f x fxs = go xs in fxs `par` LI.Chunk fx fxs -- Chunk is strict in fx. Cheers, -- Felipe.