@@ -51,6 +51,7 @@ import Prelude (Bool(..), Char, Maybe(..), Monad(..), Int,
51 fromIntegral, otherwise)
51 fromIntegral, otherwise)
52import Data.Bits ((.&.))
52import Data.Bits ((.&.))
53import Data.Text.Internal (Text(..))
53import Data.Text.Internal (Text(..))
54+import Data.Text.Private (Run(..), runText)
54import Data.Text.UnsafeChar (ord, unsafeChr, unsafeWrite)
55import Data.Text.UnsafeChar (ord, unsafeChr, unsafeWrite)
55import Data.Text.UnsafeShift (shiftL, shiftR)
56import Data.Text.UnsafeShift (shiftL, shiftR)
56import qualified Data.Text.Array as A
57import qualified Data.Text.Array as A
@@ -94,15 +95,15 @@ reverseStream (Text arr off len) = Stream next (off+len-1) (maxSize len)
95-- | /O(n)/ Convert a 'Stream Char' into a 'Text'.
96-- | /O(n)/ Convert a 'Stream Char' into a 'Text'.
96unstream :: Stream Char -> Text
97unstream :: Stream Char -> Text
97−unstream (Stream next0 s0 len) = I.textP (P.fst a) 0 (P.snd a)
98+unstream (Stream next0 s0 len) = a
99− a = A.run2 (A.new mlen >>= \arr -> outer arr mlen s0 0)
100+ a = runText (A.new mlen >>= \arr -> outer arr mlen s0 0)
100 where mlen = upperBound 4 len
101 where mlen = upperBound 4 len
101 outer arr top = loop
102 outer arr top = loop
103 loop !s !i =
104 loop !s !i =
104 case next0 s of
105 case next0 s of
105− Done -> return (arr, i)
106+ Done -> return (Run arr i)
106 Skip s' -> loop s' i
107 Skip s' -> loop s' i
107 Yield x s'
108 Yield x s'
108 | j >= top -> {-# SCC "unstream/resize" #-} do
109 | j >= top -> {-# SCC "unstream/resize" #-} do