Skip to content

Commit 8a60cdf

Browse files
committed
Add pack [] case
1 parent e6546c8 commit 8a60cdf

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/Data/Text/Internal.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ int64ToInt32 = fromIntegral
243243
-- >>> Data.Text.unpack (pack "\55555")
244244
-- "\65533"
245245
pack :: String -> Text
246+
pack [] = empty
246247
pack xs = runST $ do
247248
-- Each 'Char' takes up to 4 bytes
248249
marr <- A.new (length xs `shiftL` 2)
@@ -252,6 +253,6 @@ pack xs = runST $ do
252253
go (off + d) cs
253254
len <- go 0 xs
254255
arr <- A.unsafeFreeze marr
255-
return (text arr 0 len)
256+
return (Text arr 0 len)
256257
{-# NOINLINE [0] pack #-}
257258
-- TODO Do not calculate length xs upfront

0 commit comments

Comments
 (0)