diff options
Diffstat (limited to 'compiler/utils')
-rw-r--r-- | compiler/utils/FastString.lhs | 19 | ||||
-rw-r--r-- | compiler/utils/Outputable.lhs | 3 |
2 files changed, 5 insertions, 17 deletions
diff --git a/compiler/utils/FastString.lhs b/compiler/utils/FastString.lhs index 42bcb0ba41..0a23792050 100644 --- a/compiler/utils/FastString.lhs +++ b/compiler/utils/FastString.lhs @@ -34,10 +34,7 @@ module FastString fastZStringToByteString, mkFastBytesByteList, unsafeMkFastBytesString, - bytesFB, hashFB, - lengthFB, - appendFB, -- * FastZString FastZString, @@ -175,21 +172,11 @@ pokeCAString ptr str = in go str 0 --- | Gives the UTF-8 encoded bytes corresponding to a 'FastString' -bytesFB :: FastBytes -> [Word8] -bytesFB = BS.unpack - hashFB :: FastBytes -> Int hashFB bs = inlinePerformIO $ BS.unsafeUseAsCStringLen bs $ \(ptr, len) -> return $ hashStr (castPtr ptr) len -lengthFB :: FastBytes -> Int -lengthFB f = BS.length f - -appendFB :: FastBytes -> FastBytes -> FastBytes -appendFB = BS.append - hPutFB :: Handle -> FastBytes -> IO () hPutFB = BS.hPut @@ -473,7 +460,7 @@ unpackFS (FastString _ _ bs _) = -- | Gives the UTF-8 encoded bytes corresponding to a 'FastString' bytesFS :: FastString -> [Word8] -bytesFS fs = bytesFB $ fastStringToFastBytes fs +bytesFS fs = BS.unpack $ fastStringToFastBytes fs -- | Returns a Z-encoded version of a 'FastString'. This might be the -- original, if it was already Z-encoded. The first time this @@ -494,8 +481,8 @@ zEncodeFS fs@(FastString _ _ _ ref) = appendFS :: FastString -> FastString -> FastString appendFS fs1 fs2 = inlinePerformIO $ mkFastStringFastBytes - $ appendFB (fastStringToFastBytes fs1) - (fastStringToFastBytes fs2) + $ BS.append (fastStringToFastBytes fs1) + (fastStringToFastBytes fs2) concatFS :: [FastString] -> FastString concatFS ls = mkFastString (Prelude.concat (map unpackFS ls)) -- ToDo: do better diff --git a/compiler/utils/Outputable.lhs b/compiler/utils/Outputable.lhs index ad0b9d7639..a56037b8b7 100644 --- a/compiler/utils/Outputable.lhs +++ b/compiler/utils/Outputable.lhs @@ -84,6 +84,7 @@ import Platform import Pretty ( Doc, Mode(..) ) import Panic +import qualified Data.ByteString as BS import Data.Char import qualified Data.Map as M import qualified Data.IntMap as IM @@ -740,7 +741,7 @@ pprHsString fs = vcat (map text (showMultiLineString (unpackFS fs))) -- | Special combinator for showing string literals. pprHsBytes :: FastBytes -> SDoc -pprHsBytes fb = let escaped = concatMap escape $ bytesFB fb +pprHsBytes fb = let escaped = concatMap escape $ BS.unpack fb in vcat (map text (showMultiLineString escaped)) <> char '#' where escape :: Word8 -> String escape w = let c = chr (fromIntegral w) |