@@ -221,7 +221,7 @@ import Data.Text.Internal (Text(..), empty, firstf, mul, safe, text)
221import qualified Prelude as P
221import qualified Prelude as P
222import Data.Text.Unsafe (Iter(..), iter, iter_, lengthWord16, reverseIter,
222import Data.Text.Unsafe (Iter(..), iter, iter_, lengthWord16, reverseIter,
223 reverseIter_, unsafeHead, unsafeTail)
223 reverseIter_, unsafeHead, unsafeTail)
224−import Data.Text.Internal.Unsafe.Char (unsafeChr)
224+import Data.Text.Internal.Unsafe.Char (unsafeChr, unsafeWrite)
225import qualified Data.Text.Internal.Functions as F
225import qualified Data.Text.Internal.Functions as F
226import qualified Data.Text.Internal.Encoding.Utf16 as U16
226import qualified Data.Text.Internal.Encoding.Utf16 as U16
227import Data.Text.Internal.Search (indices)
227import Data.Text.Internal.Search (indices)
@@ -425,6 +425,22 @@ singleton :: Char -> Text
425singleton = unstream . S.singleton . safe
425singleton = unstream . S.singleton . safe
426{-# INLINE [1] singleton #-}
426{-# INLINE [1] singleton #-}
428+{-# RULES "TEXT singleton" forall a.
429+ unstream (S.singleton (safe a))
432+-- This is intended to reduce inlining bloat.
433+singleton_ :: Char -> Text
434+singleton_ c = Text (A.run x) 0 len
435+ where x :: ST s (A.MArray s)
436+ x = do arr <- A.new len
437+ _ <- unsafeWrite arr 0 d
439+ len | d < '\x10000' = 1
442+{-# NOINLINE singleton_ #-}
428-- -----------------------------------------------------------------------------
444-- -----------------------------------------------------------------------------
429-- * Basic functions
445-- * Basic functions