on master help sign in
Merge pull request #147 from bgamari/master
28631f0Bryan O'Sullivan
Data/Text.hs+10−7
@@ -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)
240#endif
240#endif
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
243#endif
244#endif
@@ -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.
575
578
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
590
593
591{-# RULES
594{-# RULES
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
594 #-}
597 #-}
595
598
596{-# RULES
599{-# RULES
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
599 #-}
602 #-}
600
603
601{-# RULES
604{-# RULES
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
604 #-}
607 #-}
605
608
606{-# RULES
609{-# RULES
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
609 #-}
612 #-}
610
613
611{-# RULES
614{-# RULES
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
614 #-}
617 #-}
615
618
616{-# RULES
619{-# RULES
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
619 #-}
622 #-}
620
623
621-- -----------------------------------------------------------------------------
624-- -----------------------------------------------------------------------------
Data/Text/Internal/Builder.hs+2
@@ -242,6 +242,8 @@ flush = Builder $ \ k buf@(Buffer p o u l) ->
242 !t = Text arr o u
242 !t = Text arr o u
243 ts <- inlineInterleaveST (k b)
243 ts <- inlineInterleaveST (k b)
244 return $! t : ts
244 return $! t : ts
245+{-# INLINE [1] flush #-}
246+-- defer inlining so that flush/flush rule may fire.
245
247
246------------------------------------------------------------------------
248------------------------------------------------------------------------
247
249