@@ -35,7 +35,7 @@ import Data.Bits ((.&.))
3535import Data.Char (ord)
3636import Data.Monoid (Monoid(..))
3737import Data.Text.Internal (Text(..))
38−import Data.Text.Lazy.Internal (defaultChunkSize)
38+import Data.Text.Lazy.Internal (smallChunkSize)
3939import Data.Text.Unsafe (inlineInterleaveST)
4040import Data.Text.UnsafeShift (shiftR)
4141import Data.Word (Word16)
@@ -133,13 +133,15 @@ fromString str = Builder $ \k (Buffer p0 o0 u0 l0) ->
133133 | l <= 1 = do
134134 arr <- A.unsafeFreeze marr
135135 let !t = Text arr o u
136− marr' <- A.unsafeNew defaultChunkSize
137− ts <- inlineInterleaveST (loop marr' 0 0 defaultChunkSize s)
136+ marr' <- A.unsafeNew chunkSize
137+ ts <- inlineInterleaveST (loop marr' 0 0 chunkSize s)
138138 return $ t : ts
139139 | otherwise = do
140140 n <- unsafeWrite marr (o+u) c
141141 loop marr o (u+n) (l-n) cs
142142 in loop p0 o0 u0 l0 str
143+ where
144+ chunkSize = smallChunkSize
143145{-# INLINE fromString #-}
144146
145147-- | /O(1)./ A Builder taking a lazy 'L.Text', satisfying
@@ -164,7 +166,7 @@ data Buffer s = Buffer {-# UNPACK #-} !(A.MArray s Word16)
164166-- buffer size. The construction work takes place if and when the
165167-- relevant part of the lazy 'L.Text' is demanded.
166168toLazyText :: Builder -> L.Text
167−toLazyText = toLazyTextWith defaultChunkSize
169+toLazyText = toLazyTextWith smallChunkSize
168170
169171-- | /O(n)./ Extract a lazy 'L.Text' from a 'Builder', using the given
170172-- size for the initial buffer. The construction work takes place if
@@ -225,7 +227,7 @@ ensureFree :: Int -> Builder
225227ensureFree !n = withSize $ \ l ->
226228 if n <= l
227229 then empty
228− else flush `append'` withBuffer (const (newBuffer (max n defaultChunkSize)))
230+ else flush `append'` withBuffer (const (newBuffer (max n smallChunkSize)))
229231{-# INLINE [0] ensureFree #-}
230232
231233-- | Ensure that @n@ many elements are available, and then use @f@ to