diff options
author | Daniel Gröber <dxld@darkboxed.org> | 2020-03-19 00:32:37 +0100 |
---|---|---|
committer | Daniel Gröber <dxld@darkboxed.org> | 2020-05-02 19:03:19 +0200 |
commit | e7ab1c588a1ebd25ecefa9f9ba0f2efedeadf1e6 (patch) | |
tree | 169e52551bab143c478e15f7446cc23926547da3 | |
parent | 6692505092c98e33eddf4b224d83c698e9756392 (diff) | |
download | haskell-e7ab1c588a1ebd25ecefa9f9ba0f2efedeadf1e6.tar.gz |
Use IO constructor instead of `stToIO . ST`
-rw-r--r-- | compiler/GHC/Data/FastString.hs | 10 | ||||
-rw-r--r-- | compiler/GHC/Utils/Encoding.hs | 2 |
2 files changed, 5 insertions, 7 deletions
diff --git a/compiler/GHC/Data/FastString.hs b/compiler/GHC/Data/FastString.hs index b29eee87fb..1b25fdfa32 100644 --- a/compiler/GHC/Data/FastString.hs +++ b/compiler/GHC/Data/FastString.hs @@ -117,16 +117,12 @@ import qualified Data.ByteString.Unsafe as BS import qualified Data.ByteString.Short as SBS import qualified Data.ByteString.Short.Internal as SBS import Foreign.C -import GHC.Exts import System.IO import Data.Data import Data.IORef import Data.Char import Data.Semigroup as Semi -import GHC.IO -import GHC.ST - import Foreign #if GHC_STAGE >= 2 @@ -134,6 +130,8 @@ import GHC.Conc.Sync (sharedCAF) #endif import GHC.Base ( unpackCString#, unpackNBytes# ) +import GHC.Exts +import GHC.IO -- | Gives the UTF-8 encoded bytes corresponding to a 'FastString' @@ -457,8 +455,8 @@ mkFastStringBytes !ptr !len = mkFastStringWith (mkNewFastStringShortByteString sbs) sbs newSBSFromPtr :: Ptr a -> Int -> IO ShortByteString -newSBSFromPtr (Ptr src#) (I# len#) = - stToIO $ ST $ \s -> +newSBSFromPtr (Ptr src#) (I# len#) = do + IO $ \s -> case newByteArray# len# s of { (# s, dst# #) -> case copyAddrToByteArray# src# dst# 0# len# s of { s -> case unsafeFreezeByteArray# dst# s of { (# s, ba# #) -> diff --git a/compiler/GHC/Utils/Encoding.hs b/compiler/GHC/Utils/Encoding.hs index 0ca0737a16..d64d31c819 100644 --- a/compiler/GHC/Utils/Encoding.hs +++ b/compiler/GHC/Utils/Encoding.hs @@ -220,11 +220,11 @@ utf8EncodeString (Ptr a#) str = go a# str go (a# `plusAddr#` off#) cs utf8EncodeShortByteString :: String -> IO ShortByteString -utf8EncodeShortByteString str = stToIO $ ST $ \s -> let !(I# len#) = utf8EncodedLength str in case newByteArray# len# s of { (# s, mba# #) -> let ST f_go = go mba# 0# str in case f_go s of { (# s, () #) -> +utf8EncodeShortByteString str = IO $ \s -> case unsafeFreezeByteArray# mba# s of { (# s, ba# #) -> (# s, SBS ba# #) }}} where |