on master help sign in
Remove unexpected laziness from lazy count
2b507cdBryan O'Sullivan
Data/Text/Lazy.hs+3−3
@@ -1246,9 +1246,9 @@ index t n = S.index (stream t) n
1246count :: Text -> Text -> Int64
1246count :: Text -> Text -> Int64
1247count pat src
1247count pat src
1248 | null pat = emptyError "count"
1248 | null pat = emptyError "count"
1249− | otherwise = len (indices pat src)
1249+ | otherwise = go 0 (indices pat src)
1250− where len [] = 0
1250+ where go !n [] = n
1251− len (_:xs) = 1 + len xs
1251+ go !n (_:xs) = go (n+1) xs
1252{-# INLINE [1] count #-}
1252{-# INLINE [1] count #-}
1253
1253
1254{-# RULES
1254{-# RULES