summaryrefslogtreecommitdiff
path: root/compiler/GHC/Utils/BufHandle.hs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/GHC/Utils/BufHandle.hs')
-rw-r--r--compiler/GHC/Utils/BufHandle.hs32
1 files changed, 16 insertions, 16 deletions
diff --git a/compiler/GHC/Utils/BufHandle.hs b/compiler/GHC/Utils/BufHandle.hs
index 79d2dbed60..0cc1d015b7 100644
--- a/compiler/GHC/Utils/BufHandle.hs
+++ b/compiler/GHC/Utils/BufHandle.hs
@@ -59,13 +59,13 @@ buf_size = 8192
bPutChar :: BufHandle -> Char -> IO ()
bPutChar b@(BufHandle buf r hdl) !c = do
- i <- readFastMutInt r
+ i <- readFirstFastMutInt r
if (i >= buf_size)
then do hPutBuf hdl buf buf_size
- writeFastMutInt r 0
+ writeFirstFastMutInt r 0
bPutChar b c
else do pokeElemOff buf i (fromIntegral (ord c) :: Word8)
- writeFastMutInt r (i+1)
+ writeFirstFastMutInt r (i+1)
-- Equivalent of the text/str, text/unpackNBytes#, text/[] rules
-- in GHC.Utils.Ppr.
@@ -85,9 +85,9 @@ bPutChar b@(BufHandle buf r hdl) !c = do
bPutStr :: BufHandle -> String -> IO ()
bPutStr (BufHandle buf r hdl) !str = do
- i <- readFastMutInt r
+ i <- readFirstFastMutInt r
loop str i
- where loop "" !i = do writeFastMutInt r i; return ()
+ where loop "" !i = do writeFirstFastMutInt r i; return ()
loop (c:cs) !i
| i >= buf_size = do
hPutBuf hdl buf buf_size
@@ -107,46 +107,46 @@ bPutBS b bs = BS.unsafeUseAsCStringLen bs $ bPutCStringLen b
bPutCStringLen :: BufHandle -> CStringLen -> IO ()
bPutCStringLen b@(BufHandle buf r hdl) cstr@(ptr, len) = do
- i <- readFastMutInt r
+ i <- readFirstFastMutInt r
if (i + len) >= buf_size
then do hPutBuf hdl buf i
- writeFastMutInt r 0
+ writeFirstFastMutInt r 0
if (len >= buf_size)
then hPutBuf hdl ptr len
else bPutCStringLen b cstr
else do
copyBytes (buf `plusPtr` i) ptr len
- writeFastMutInt r (i + len)
+ writeFirstFastMutInt r (i + len)
bPutPtrString :: BufHandle -> PtrString -> IO ()
bPutPtrString b@(BufHandle buf r hdl) l@(PtrString a len) = l `seq` do
- i <- readFastMutInt r
+ i <- readFirstFastMutInt r
if (i+len) >= buf_size
then do hPutBuf hdl buf i
- writeFastMutInt r 0
+ writeFirstFastMutInt r 0
if (len >= buf_size)
then hPutBuf hdl a len
else bPutPtrString b l
else do
copyBytes (buf `plusPtr` i) a len
- writeFastMutInt r (i+len)
+ writeFirstFastMutInt r (i+len)
-- | Replicate an 8-bit character
bPutReplicate :: BufHandle -> Int -> Char -> IO ()
bPutReplicate (BufHandle buf r hdl) len c = do
- i <- readFastMutInt r
+ i <- readFirstFastMutInt r
let oc = fromIntegral (ord c)
if (i+len) < buf_size
then do
fillBytes (buf `plusPtr` i) oc len
- writeFastMutInt r (i+len)
+ writeFirstFastMutInt r (i+len)
else do
-- flush the current buffer
when (i /= 0) $ hPutBuf hdl buf i
if (len < buf_size)
then do
fillBytes buf oc len
- writeFastMutInt r len
+ writeFirstFastMutInt r len
else do
-- fill a full buffer
fillBytes buf oc buf_size
@@ -154,12 +154,12 @@ bPutReplicate (BufHandle buf r hdl) len c = do
let go n | n >= buf_size = do
hPutBuf hdl buf buf_size
go (n-buf_size)
- | otherwise = writeFastMutInt r n
+ | otherwise = writeFirstFastMutInt r n
go len
bFlush :: BufHandle -> IO ()
bFlush (BufHandle buf r hdl) = do
- i <- readFastMutInt r
+ i <- readFirstFastMutInt r
when (i > 0) $ hPutBuf hdl buf i
free buf
return ()