summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIavor S. Diatchki <iavor.diatchki@gmail.com>2014-02-24 13:54:23 -0800
committerIavor S. Diatchki <iavor.diatchki@gmail.com>2014-02-24 13:54:23 -0800
commit013ab26ccb84ddec5eed3ba42d8648b32dc79b38 (patch)
treeb03969fe0282ae31917cb5b821c0e2f7096c057a
parenta85e57deb287abdcdac8fb065ab0b20efe074d96 (diff)
parenteafdb65174bc2149881468a060d08127a3f04074 (diff)
Merge pull request #5 from odr/masterHEADni/mastercd/mastercd/HEADmaster
matchUntil was changed for performance reason
-rw-r--r--.gitignore7
-rw-r--r--Codec/MIME/Parse.hs13
-rw-r--r--mime.cabal2
3 files changed, 18 insertions, 4 deletions
diff --git a/.gitignore b/.gitignore
index 9b1c8b1..2b206ec 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,8 @@
/dist
+**.hi
+**.o
+**.swp
+/.cabal-sandbox
+*.swp
+cabal.sandbox.config
+**tags
diff --git a/Codec/MIME/Parse.hs b/Codec/MIME/Parse.hs
index 2843903..f9dfeb2 100644
--- a/Codec/MIME/Parse.hs
+++ b/Codec/MIME/Parse.hs
@@ -26,6 +26,7 @@ module Codec.MIME.Parse
import Codec.MIME.Type
import Codec.MIME.Decode
+import Control.Arrow(second)
import Data.Char
import Data.Maybe
@@ -245,12 +246,18 @@ untilMatch a b | T.null a = Just b
| otherwise = untilMatch a $ T.tail b
matchUntil :: T.Text -> T.Text -> (T.Text, T.Text)
-matchUntil _ "" = ("", "")
-matchUntil str xs
+-- searching str; returning parts before str and after str
+matchUntil str = second (T.drop $ T.length str) . T.breakOn str
+
+{-
+matchUntil' :: T.Text -> T.Text -> (T.Text, T.Text)
+matchUntil' _ "" = ("", "")
+matchUntil' str xs
| T.null xs = mempty
-- slow, but it'll do for now.
| str `T.isPrefixOf` xs = ("", T.drop (T.length str) xs)
- | otherwise = let (as,bs) = matchUntil str $ T.tail xs in (T.take 1 xs <> as, bs)
+ | otherwise = let (as,bs) = matchUntil' str $ T.tail xs in (T.take 1 xs <> as, bs)
+-}
isHSpace :: Char -> Bool
isHSpace c = c == ' ' || c == '\t'
diff --git a/mime.cabal b/mime.cabal
index 2ccd845..a15f753 100644
--- a/mime.cabal
+++ b/mime.cabal
@@ -1,5 +1,5 @@
name: mime
-version: 0.4.0
+version: 0.4.0.1
synopsis: Working with MIME types.
description: Working with MIME types.
category: Codec