@@ -238,6 +238,7 @@ import Data.ByteString (ByteString)
238import qualified Data.Text.Lazy as L
238import qualified Data.Text.Lazy as L
239import Data.Int (Int64)
239import Data.Int (Int64)
241+import GHC.Base (eqInt, neInt, gtInt, geInt, ltInt, leInt)
241#if __GLASGOW_HASKELL__ >= 708
242#if __GLASGOW_HASKELL__ >= 708
242import qualified GHC.Exts as Exts
243import qualified GHC.Exts as Exts
@@ -571,7 +572,9 @@ isSingleton = S.isSingleton . stream
571-- Subject to fusion.
572-- Subject to fusion.
572length :: Text -> Int
573length :: Text -> Int
573length t = S.length (stream t)
574length t = S.length (stream t)
574−{-# INLINE length #-}
575+{-# INLINE [0] length #-}
576+-- length needs to be phased after the compareN/length rules otherwise
577+-- it may inline before the rules have an opportunity to fire.
576-- | /O(n)/ Compare the count of characters in a 'Text' to a number.
579-- | /O(n)/ Compare the count of characters in a 'Text' to a number.
577-- Subject to fusion.
580-- Subject to fusion.
@@ -590,32 +593,32 @@ compareLength t n = S.compareLengthI (stream t) n
592"TEXT ==N/length -> compareLength/==EQ" [~1] forall t n.
595"TEXT ==N/length -> compareLength/==EQ" [~1] forall t n.
593− (==) (length t) n = compareLength t n == EQ
596+ eqInt (length t) n = compareLength t n == EQ
597"TEXT /=N/length -> compareLength//=EQ" [~1] forall t n.
600"TEXT /=N/length -> compareLength//=EQ" [~1] forall t n.
598− (/=) (length t) n = compareLength t n /= EQ
601+ neInt (length t) n = compareLength t n /= EQ
602"TEXT <N/length -> compareLength/==LT" [~1] forall t n.
605"TEXT <N/length -> compareLength/==LT" [~1] forall t n.
603− (<) (length t) n = compareLength t n == LT
606+ ltInt (length t) n = compareLength t n == LT
607"TEXT <=N/length -> compareLength//=GT" [~1] forall t n.
610"TEXT <=N/length -> compareLength//=GT" [~1] forall t n.
608− (<=) (length t) n = compareLength t n /= GT
611+ leInt (length t) n = compareLength t n /= GT
612"TEXT >N/length -> compareLength/==GT" [~1] forall t n.
615"TEXT >N/length -> compareLength/==GT" [~1] forall t n.
613− (>) (length t) n = compareLength t n == GT
616+ gtInt (length t) n = compareLength t n == GT
617"TEXT >=N/length -> compareLength//=LT" [~1] forall t n.
620"TEXT >=N/length -> compareLength//=LT" [~1] forall t n.
618− (>=) (length t) n = compareLength t n /= LT
621+ geInt (length t) n = compareLength t n /= LT
621-- -----------------------------------------------------------------------------
624-- -----------------------------------------------------------------------------