Commits

wren romano committed a72b6b0

Data.Attoparsec.Char8: Sped up isSpace and isSpace_w8 by another 14%.

Comments (0)

Files changed (1)

Data/Attoparsec/Char8.hs

 -- byte. For a Unicode-aware and only slightly slower predicate,
 -- use 'Data.Char.isSpace'
 isSpace :: Char -> Bool
-isSpace c = (c == ' ') || ('\t' <= c && c <= '\r')
+isSpace c = (x <= '\r' && '\t' <= c) || (c == ' ')
 {-# INLINE isSpace #-}
 
 -- | Fast 'Word8' predicate for matching ASCII space characters.
 isSpace_w8 :: Word8 -> Bool
-isSpace_w8 w = (w == 32) || (9 <= w && w <= 13)
+isSpace_w8 w = (w <= 0x0D && 0x09 <= w) || (w == 0x20)
 {-# INLINE isSpace_w8 #-}
+-- 0x09..0x0D,0x20 == "\t\n\v\f\r "
 
 
 -- | Parse a space character.