bytestring has rewrite rules like
{-# RULES
"ByteString specialise takeWhile (x /=)" forall x.
takeWhile (x `neWord8`) = fst . breakByte x
"ByteString specialise takeWhile (/= x)" forall x.
takeWhile (`neWord8` x) = fst . breakByte x
#-}
{-# RULES
"ByteString specialise dropWhile (x /=)" forall x.
dropWhile (x `neWord8`) = snd . breakByte x
"ByteString specialise dropWhile (/= x)" forall x.
dropWhile (`neWord8` x) = snd . breakByte x
#-}
{-# RULES
"ByteString specialise break (x ==)" forall x.
break (x `eqWord8`) = breakByte x
"ByteString specialise break (== x)" forall x.
break (`eqWord8` x) = breakByte x
#-}
I think we should do the same, rewriting Data.Text.break as Data.Text.breakOn and same for lazy text.
(See https://discourse.haskell.org/t/blog-5x-speedup-changing-break-to-elemindex/13946 for context)
bytestringhas rewrite rules like{-# RULES "ByteString specialise takeWhile (x /=)" forall x. takeWhile (x `neWord8`) = fst . breakByte x "ByteString specialise takeWhile (/= x)" forall x. takeWhile (`neWord8` x) = fst . breakByte x #-} {-# RULES "ByteString specialise dropWhile (x /=)" forall x. dropWhile (x `neWord8`) = snd . breakByte x "ByteString specialise dropWhile (/= x)" forall x. dropWhile (`neWord8` x) = snd . breakByte x #-} {-# RULES "ByteString specialise break (x ==)" forall x. break (x `eqWord8`) = breakByte x "ByteString specialise break (== x)" forall x. break (`eqWord8` x) = breakByte x #-}I think we should do the same, rewriting
Data.Text.breakasData.Text.breakOnand same for lazy text.(See https://discourse.haskell.org/t/blog-5x-speedup-changing-break-to-elemindex/13946 for context)