X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Futils%2FFastString.lhs;h=26f687c40fa99b19a8b43b4baaf724242b84665d;hb=fd7f8e936e50b3ee589efc36ac2fc54cc6c05300;hp=ea307799c424f6f164fbf1074f49a6c819e14750;hpb=0065d5ab628975892cea1ec7303f968c3338cbe1;p=ghc-hetmet.git diff --git a/compiler/utils/FastString.lhs b/compiler/utils/FastString.lhs index ea30779..26f687c 100644 --- a/compiler/utils/FastString.lhs +++ b/compiler/utils/FastString.lhs @@ -24,6 +24,7 @@ module FastString -- ** Construction mkFastString, mkFastStringBytes, + mkFastStringByteList, mkFastStringForeignPtr, mkFastString#, mkZFastString, @@ -275,6 +276,15 @@ mkFastString str = utf8EncodeString ptr str mkFastStringForeignPtr ptr buf l +-- | Creates a 'FastString' from a UTF-8 encoded @[Word8]@ +mkFastStringByteList :: [Word8] -> FastString +mkFastStringByteList str = + inlinePerformIO $ do + let l = Prelude.length str + buf <- mallocForeignPtrBytes l + withForeignPtr buf $ \ptr -> do + pokeArray (castPtr ptr) str + mkFastStringForeignPtr ptr buf l -- | Creates a Z-encoded 'FastString' from a 'String' mkZFastString :: String -> FastString