diff options
author | Ian Lynagh <ian@well-typed.com> | 2012-12-13 20:20:58 +0000 |
---|---|---|
committer | Ian Lynagh <ian@well-typed.com> | 2012-12-13 21:31:02 +0000 |
commit | 7651b6799523e55e132ed8f5ccd5bb3f21b9a0ac (patch) | |
tree | abc75a7a48eb43c38a342575a7aaf837630a6f6f /compiler/ghci | |
parent | d5b5d48881b3adbf3bd5e177ee6ef506e589b882 (diff) | |
download | haskell-7651b6799523e55e132ed8f5ccd5bb3f21b9a0ac.tar.gz |
Make FastBytes a synonym for ByteString
A step on the way to getting rid of FastBytes
slow nofib Compile times look like:
-1 s.d. -2.4%
+1 s.d. +3.4%
Average +0.4%
but looking at the times for the longer-running compilations I think the
change is just noise.
Diffstat (limited to 'compiler/ghci')
-rw-r--r-- | compiler/ghci/ByteCodeGen.lhs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/compiler/ghci/ByteCodeGen.lhs b/compiler/ghci/ByteCodeGen.lhs index 2b332a4581..9c9526de27 100644 --- a/compiler/ghci/ByteCodeGen.lhs +++ b/compiler/ghci/ByteCodeGen.lhs @@ -63,6 +63,8 @@ import BreakArray import Data.Maybe import Module +import qualified Data.ByteString as BS +import qualified Data.ByteString.Unsafe as BS import Data.Map (Map) import qualified Data.Map as Map import qualified FiniteMap as Map @@ -1266,18 +1268,18 @@ pushAtom _ _ (AnnLit lit) = do where pushStr s = let getMallocvilleAddr - = case s of - FastBytes n fp -> + = -- we could grab the Ptr from the ForeignPtr, -- but then we have no way to control its lifetime. -- In reality it'll probably stay alive long enoungh -- by virtue of the global FastString table, but -- to be on the safe side we copy the string into -- a malloc'd area of memory. - do ptr <- ioToBc (mallocBytes (n+1)) + do let n = BS.length s + ptr <- ioToBc (mallocBytes (n+1)) recordMallocBc ptr ioToBc ( - withForeignPtr fp $ \p -> do + BS.unsafeUseAsCString s $ \p -> do memcpy ptr p (fromIntegral n) pokeByteOff ptr n (fromIntegral (ord '\0') :: Word8) return ptr |