git.iko.soy/typeable/attoparsec
on master help sign in
Use special unsigned tests to reduce branches for isDigit_w8, isSpace_w8
64445b0Kyle Van Berendonck
Data/Attoparsec/ByteString/Char8.hs+5−2
@@ -235,7 +235,8 @@ isDigit c = c >= '0' && c <= '9'
235
235
236-- | A fast digit predicate.
236-- | A fast digit predicate.
237isDigit_w8 :: Word8 -> Bool
237isDigit_w8 :: Word8 -> Bool
238−isDigit_w8 w = w >= 48 && w <= 57
238+isDigit_w8 w | w - 48 <= 9 = True
239+ | otherwise = False
239{-# INLINE isDigit_w8 #-}
240{-# INLINE isDigit_w8 #-}
240
241
241-- | Match any character.
242-- | Match any character.
@@ -272,7 +273,9 @@ isSpace c = (c == ' ') || ('\t' <= c && c <= '\r')
272
273
273-- | Fast 'Word8' predicate for matching ASCII space characters.
274-- | Fast 'Word8' predicate for matching ASCII space characters.
274isSpace_w8 :: Word8 -> Bool
275isSpace_w8 :: Word8 -> Bool
275−isSpace_w8 w = (w == 32) || (9 <= w && w <= 13)
276+isSpace_w8 w | w == 32 = True
277+ | w - 9 <= 4 = True
278+ | otherwise = False
276{-# INLINE isSpace_w8 #-}
279{-# INLINE isSpace_w8 #-}
277
280
278
281