@@ -1,8 +1,8 @@
11-----------------------------------------------------------------------------
22-- |
33-- Module : Text.ParserCombinators.ByteStringParser
4−-- Copyright : (c) Daan Leijen 1999-2001, Jeremy Shaw 2006, Bryan O'Sullivan 2007
5−-- License : BSD-style (see the file libraries/parsec/LICENSE)
4+-- Copyright : Daan Leijen 1999-2001, Jeremy Shaw 2006, Bryan O'Sullivan 2007-2008
5+-- License : BSD3
66--
77-- Maintainer : bos@serpentine.com
88-- Stability : experimental
@@ -75,7 +75,7 @@ import qualified Data.ByteString.Lazy.Char8 as LB
7575import qualified Data.ByteString.Lazy.Internal as LB
7676import Data.Char (isDigit, isLetter, isSpace, toLower)
7777import Data.Int (Int64)
78−import qualified Data.Set as S
78+import Text.ParserCombinators.ByteStringParser.FastSet (FastSet, member, set)
7979import Prelude hiding (takeWhile)
8080
8181type ParseError = String
@@ -209,19 +209,20 @@ notChar :: Char -> Parser Char
209209notChar c = satisfy (/= c) <?> "not " ++ [c]
210210{-# INLINE notChar #-}
211211
212−charClass :: String -> S.Set Char
213−charClass s = S.fromList (go s)
212+charClass :: String -> FastSet
213+charClass = set . SB.pack . go
214214 where go (a:'-':b:xs) = [a..b] ++ go xs
215215 go (x:xs) = x : go xs
216216 go _ = ""
217217
218218inClass :: String -> Char -> Bool
219−inClass s = (`S.member` set)
220− where set = charClass s
219+inClass s = (`member` myset)
220+ where myset = charClass s
221+{-# INLINE inClass #-}
221222
222223notInClass :: String -> Char -> Bool
223−notInClass s = (`S.notMember` set)
224− where set = charClass s
224+notInClass s = not . inClass s
225+{-# INLINE notInClass #-}
225226
226227sepBy :: Parser a -> Parser s -> Parser [a]
227228sepBy p s = liftM2 (:) p ((s >> sepBy1 p s) <|> return []) <|> return []