summaryrefslogtreecommitdiff
path: root/compiler/GHC/Hs
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2021-01-18 11:53:55 +0000
committerMatthew Pickering <matthewtpickering@gmail.com>2021-03-03 19:11:08 +0000
commitf121ffe4be7dd156701d856fbc9afeaf50e7038e (patch)
tree1c2f89f47a79d339cd8677c3f4a427054a9ac30a /compiler/GHC/Hs
parent91d09039a8d6665097c1aa12f6fb3e6e45d4acca (diff)
downloadhaskell-f121ffe4be7dd156701d856fbc9afeaf50e7038e.tar.gz
Don't use FastString to convert string to UTF8
Diffstat (limited to 'compiler/GHC/Hs')
-rw-r--r--compiler/GHC/Hs/Doc.hs11
1 files changed, 1 insertions, 10 deletions
diff --git a/compiler/GHC/Hs/Doc.hs b/compiler/GHC/Hs/Doc.hs
index 400df5cdf9..207b65f2fd 100644
--- a/compiler/GHC/Hs/Doc.hs
+++ b/compiler/GHC/Hs/Doc.hs
@@ -27,7 +27,6 @@ import GHC.Prelude
import GHC.Utils.Binary
import GHC.Utils.Encoding
-import GHC.Utils.IO.Unsafe
import GHC.Types.Name
import GHC.Utils.Outputable as Outputable
import GHC.Types.SrcLoc
@@ -35,12 +34,10 @@ import GHC.Types.SrcLoc
import Data.ByteString (ByteString)
import qualified Data.ByteString as BS
import qualified Data.ByteString.Char8 as C8
-import qualified Data.ByteString.Internal as BS
import Data.Data
import Data.Map (Map)
import qualified Data.Map as Map
import Data.Maybe
-import Foreign
-- | Haskell Documentation String
--
@@ -68,13 +65,7 @@ isEmptyDocString :: HsDocString -> Bool
isEmptyDocString (HsDocString bs) = BS.null bs
mkHsDocString :: String -> HsDocString
-mkHsDocString s =
- inlinePerformIO $ do
- let len = utf8EncodedLength s
- buf <- mallocForeignPtrBytes len
- withForeignPtr buf $ \ptr -> do
- utf8EncodeString ptr s
- pure (HsDocString (BS.fromForeignPtr buf 0 len))
+mkHsDocString s = HsDocString (utf8EncodeString s)
-- | Create a 'HsDocString' from a UTF8-encoded 'ByteString'.
mkHsDocStringUtf8ByteString :: ByteString -> HsDocString