From 25561b5ef632ebe4fa5dccc73751fa418bda1196 Mon Sep 17 00:00:00 2001 From: Don Stewart Date: Mon, 20 Nov 2006 12:02:42 +0000 Subject: [PATCH] One less unsafeCoerce# in the tree --- Data/ByteString/Char8.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Data/ByteString/Char8.hs b/Data/ByteString/Char8.hs index 460f18b..a62ae57 100644 --- a/Data/ByteString/Char8.hs +++ b/Data/ByteString/Char8.hs @@ -265,7 +265,7 @@ import Control.Exception (bracket) import Foreign #if defined(__GLASGOW_HASKELL__) -import GHC.Base (Char(..),unpackCString#,unsafeCoerce#) +import GHC.Base (Char(..),unpackCString#,ord#,int2Word#) import GHC.IOBase (IO(..),stToIO) import GHC.Prim (Addr#,writeWord8OffAddr#,plusAddr#) import GHC.Ptr (Ptr(..)) @@ -301,7 +301,7 @@ pack str = B.unsafeCreate (P.length str) $ \(Ptr p) -> stToIO (go p str) where go :: Addr# -> [Char] -> ST a () go _ [] = return () - go p (C# c:cs) = writeByte p (unsafeCoerce# c) >> go (p `plusAddr#` 1#) cs + go p (C# c:cs) = writeByte p (int2Word# (ord# c)) >> go (p `plusAddr#` 1#) cs writeByte p c = ST $ \s# -> case writeWord8OffAddr# p 0# c s# of s2# -> (# s2#, () #) -- 1.7.10.4