diff options
author | Krzysztof Gogolewski <krzysztof.gogolewski@tweag.io> | 2022-10-24 19:52:40 +0200 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2022-10-25 18:10:19 -0400 |
commit | f5a486eb3233b0e577333f04d2087d0f6741af87 (patch) | |
tree | ecb7fd5de195ccfd58859d8644b95852ac8367c6 /compiler/GHC/Data | |
parent | 1fd7f201a5afb9e8a26099da5ec86016bb487c92 (diff) | |
download | haskell-f5a486eb3233b0e577333f04d2087d0f6741af87.tar.gz |
Cleanup String/FastString conversions
Remove unused mkPtrString and isUnderscoreFS.
We no longer use mkPtrString since 1d03d8bef96.
Remove unnecessary conversions between FastString and String and back.
Diffstat (limited to 'compiler/GHC/Data')
-rw-r--r-- | compiler/GHC/Data/FastString.hs | 34 |
1 files changed, 2 insertions, 32 deletions
diff --git a/compiler/GHC/Data/FastString.hs b/compiler/GHC/Data/FastString.hs index 483d40cca1..98814fa6b3 100644 --- a/compiler/GHC/Data/FastString.hs +++ b/compiler/GHC/Data/FastString.hs @@ -30,8 +30,8 @@ -- * Pointer and size of a Latin-1 encoded string. -- * Practically no operations. -- * Outputting them is fast. --- * Generated by 'mkPtrString'. --- * Length of string literals (mkPtrString "abc") is computed statically +-- * Generated by 'mkPtrString#'. +-- * Length of string literals (mkPtrString# "abc"#) is computed statically -- * Turn into 'GHC.Utils.Outputable.SDoc' with 'GHC.Utils.Outputable.ptext' -- * Requires manual memory management. -- Improper use may lead to memory leaks or dangling pointers. @@ -85,7 +85,6 @@ module GHC.Data.FastString concatFS, consFS, nilFS, - isUnderscoreFS, lexicalCompareFS, uniqCompareFS, @@ -101,7 +100,6 @@ module GHC.Data.FastString -- ** Construction mkPtrString#, - mkPtrString, -- ** Deconstruction unpackPtrString, @@ -134,7 +132,6 @@ import Foreign.C import System.IO import Data.Data import Data.IORef -import Data.Char import Data.Semigroup as Semi import Foreign @@ -623,9 +620,6 @@ uniqueOfFS fs = uniq fs nilFS :: FastString nilFS = mkFastString "" -isUnderscoreFS :: FastString -> Bool -isUnderscoreFS fs = fs == fsLit "_" - -- ----------------------------------------------------------------------------- -- Stats @@ -667,30 +661,6 @@ mkPtrString# :: Addr# -> PtrString {-# INLINE mkPtrString# #-} mkPtrString# a# = PtrString (Ptr a#) (ptrStrLength (Ptr a#)) --- | Encode a 'String' into a newly allocated 'PtrString' using Latin-1 --- encoding. The original string must not contain non-Latin-1 characters --- (above codepoint @0xff@). -{-# NOINLINE[0] mkPtrString #-} -- see rules below -mkPtrString :: String -> PtrString -mkPtrString s = - -- we don't use `unsafeDupablePerformIO` here to avoid potential memory leaks - -- and because someone might be using `eqAddr#` to check for string equality. - unsafePerformIO (do - let len = length s - p <- mallocBytes len - let - loop :: Int -> String -> IO () - loop !_ [] = return () - loop n (c:cs) = do - pokeByteOff p n (fromIntegral (ord c) :: Word8) - loop (1+n) cs - loop 0 s - return (PtrString p len) - ) - -{-# RULES "mkPtrString" - forall x . mkPtrString (unpackCString# x) = mkPtrString# x #-} - -- | Decode a 'PtrString' back into a 'String' using Latin-1 encoding. -- This does not free the memory associated with 'PtrString'. unpackPtrString :: PtrString -> String |