on master help sign in
Improve performance of strict uncons by ~5%
9b5ffb3Bryan O'Sullivan
Data/Text.hs+2−2
@@ -485,8 +485,8 @@ head t = S.head (stream t)
485uncons :: Text -> Maybe (Char, Text)
485uncons :: Text -> Maybe (Char, Text)
486uncons t@(Text arr off len)
486uncons t@(Text arr off len)
487 | len <= 0 = Nothing
487 | len <= 0 = Nothing
488+ | otherwise = Just $ let !(Iter c d) = iter t 0
488− | otherwise = Just (c, text arr (off+d) (len-d))
489+ in (c, text arr (off+d) (len-d))
489− where Iter c d = iter t 0
490{-# INLINE [1] uncons #-}
490{-# INLINE [1] uncons #-}
491
491
492-- | Lifted from Control.Arrow and specialized.
492-- | Lifted from Control.Arrow and specialized.