summaryrefslogtreecommitdiffstats
path: root/Codec/MIME
diff options
context:
space:
mode:
authorodr <olshanskydr@gmail.com>2014-02-10 16:22:24 +0400
committerodr <olshanskydr@gmail.com>2014-02-10 16:22:24 +0400
commiteafdb65174bc2149881468a060d08127a3f04074 (patch)
treeb03969fe0282ae31917cb5b821c0e2f7096c057a /Codec/MIME
parent1823a3dd5443d98eab577988e9627fe74f3491fc (diff)
matchUntil was changed for performance
Diffstat (limited to 'Codec/MIME')
-rw-r--r--Codec/MIME/Parse.hs13
1 files changed, 10 insertions, 3 deletions
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'