We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e6546c8 commit 8a60cdfCopy full SHA for 8a60cdf
src/Data/Text/Internal.hs
@@ -243,6 +243,7 @@ int64ToInt32 = fromIntegral
243
-- >>> Data.Text.unpack (pack "\55555")
244
-- "\65533"
245
pack :: String -> Text
246
+pack [] = empty
247
pack xs = runST $ do
248
-- Each 'Char' takes up to 4 bytes
249
marr <- A.new (length xs `shiftL` 2)
@@ -252,6 +253,6 @@ pack xs = runST $ do
252
253
go (off + d) cs
254
len <- go 0 xs
255
arr <- A.unsafeFreeze marr
- return (text arr 0 len)
256
+ return (Text arr 0 len)
257
{-# NOINLINE [0] pack #-}
258
-- TODO Do not calculate length xs upfront
0 commit comments