@@ -72,11 +72,11 @@ import Foreign.Marshal.Utils (with)
7272import Foreign.Ptr (Ptr, minusPtr, plusPtr)
7373import Foreign.Storable (peek, poke)
7474import GHC.Base (MutableByteArray#)
75−import System.IO.Unsafe (unsafePerformIO)
7675import qualified Data.Text.Array as A
7776import qualified Data.Text.Encoding.Fusion as E
7877import qualified Data.Text.Encoding.Utf16 as U16
7978import qualified Data.Text.Fusion as F
79+import Data.Text.Unsafe (unsafeDupablePerformIO)
8080
8181-- $strict
8282--
@@ -157,12 +157,12 @@ decodeUtf8 = decodeUtf8With strictDecode
157157-- If the input contains any invalid UTF-8 data, the relevant
158158-- exception will be returned, otherwise the decoded text.
159159decodeUtf8' :: ByteString -> Either UnicodeException Text
160−decodeUtf8' = unsafePerformIO . try . evaluate . decodeUtf8With strictDecode
160+decodeUtf8' = unsafeDupablePerformIO . try . evaluate . decodeUtf8With strictDecode
161161{-# INLINE decodeUtf8' #-}
162162
163163-- | Encode text using UTF-8 encoding.
164164encodeUtf8 :: Text -> ByteString
165−encodeUtf8 (Text arr off len) = unsafePerformIO $ do
165+encodeUtf8 (Text arr off len) = unsafeDupablePerformIO $ do
166166 let size0 = max len 4
167167 mallocByteString size0 >>= start size0 off 0
168168 where