@@ -35,7 +35,7 @@ import Data.Bits ((.&.))
35import Data.Char (ord)
35import Data.Char (ord)
36import Data.Monoid (Monoid(..))
36import Data.Monoid (Monoid(..))
37import Data.Text.Internal (Text(..))
37import Data.Text.Internal (Text(..))
38−import Data.Text.Lazy.Internal (defaultChunkSize)
38+import Data.Text.Lazy.Internal (smallChunkSize)
39import Data.Text.Unsafe (inlineInterleaveST)
39import Data.Text.Unsafe (inlineInterleaveST)
40import Data.Text.UnsafeShift (shiftR)
40import Data.Text.UnsafeShift (shiftR)
41import Data.Word (Word16)
41import Data.Word (Word16)
@@ -133,13 +133,15 @@ fromString str = Builder $ \k (Buffer p0 o0 u0 l0) ->
133 | l <= 1 = do
133 | l <= 1 = do
134 arr <- A.unsafeFreeze marr
134 arr <- A.unsafeFreeze marr
135 let !t = Text arr o u
135 let !t = Text arr o u
136− marr' <- A.unsafeNew defaultChunkSize
136+ marr' <- A.unsafeNew chunkSize
137− ts <- inlineInterleaveST (loop marr' 0 0 defaultChunkSize s)
137+ ts <- inlineInterleaveST (loop marr' 0 0 chunkSize s)
138 return $ t : ts
138 return $ t : ts
139 | otherwise = do
139 | otherwise = do
140 n <- unsafeWrite marr (o+u) c
140 n <- unsafeWrite marr (o+u) c
141 loop marr o (u+n) (l-n) cs
141 loop marr o (u+n) (l-n) cs
142 in loop p0 o0 u0 l0 str
142 in loop p0 o0 u0 l0 str
144+ chunkSize = smallChunkSize
143{-# INLINE fromString #-}
145{-# INLINE fromString #-}
145-- | /O(1)./ A Builder taking a lazy 'L.Text', satisfying
147-- | /O(1)./ A Builder taking a lazy 'L.Text', satisfying
@@ -164,7 +166,7 @@ data Buffer s = Buffer {-# UNPACK #-} !(A.MArray s Word16)
164-- buffer size. The construction work takes place if and when the
166-- buffer size. The construction work takes place if and when the
165-- relevant part of the lazy 'L.Text' is demanded.
167-- relevant part of the lazy 'L.Text' is demanded.
166toLazyText :: Builder -> L.Text
168toLazyText :: Builder -> L.Text
167−toLazyText = toLazyTextWith defaultChunkSize
169+toLazyText = toLazyTextWith smallChunkSize
169-- | /O(n)./ Extract a lazy 'L.Text' from a 'Builder', using the given
171-- | /O(n)./ Extract a lazy 'L.Text' from a 'Builder', using the given
170-- size for the initial buffer. The construction work takes place if
172-- size for the initial buffer. The construction work takes place if
@@ -225,7 +227,7 @@ ensureFree :: Int -> Builder
225ensureFree !n = withSize $ \ l ->
227ensureFree !n = withSize $ \ l ->
226 if n <= l
228 if n <= l
227 then empty
229 then empty
228− else flush `append'` withBuffer (const (newBuffer (max n defaultChunkSize)))
230+ else flush `append'` withBuffer (const (newBuffer (max n smallChunkSize)))
229{-# INLINE [0] ensureFree #-}
231{-# INLINE [0] ensureFree #-}
231-- | Ensure that @n@ many elements are available, and then use @f@ to
233-- | Ensure that @n@ many elements are available, and then use @f@ to