summaryrefslogtreecommitdiff
path: root/libraries
diff options
context:
space:
mode:
authorNeil Mitchell <ndmitchell@gmail.com>2018-09-07 19:02:18 +0100
committerÖmer Sinan Ağacan <omeragacan@gmail.com>2018-09-08 12:17:33 +0300
commit510c5f4f22aca29a9c36fd993ac79e9077b28173 (patch)
treed8aebfcc84312542b470c87469662f3c30f937fe /libraries
parent62cd44013eaa6f366d4130492a9d6c50b0765d54 (diff)
downloadhaskell-510c5f4f22aca29a9c36fd993ac79e9077b28173.tar.gz
Avoid creating unevaluated Int thunks when iterating in GHC.Foreign
Diffstat (limited to 'libraries')
-rw-r--r--libraries/base/GHC/Foreign.hs8
1 files changed, 4 insertions, 4 deletions
diff --git a/libraries/base/GHC/Foreign.hs b/libraries/base/GHC/Foreign.hs
index cc985ed5be..196005d3a7 100644
--- a/libraries/base/GHC/Foreign.hs
+++ b/libraries/base/GHC/Foreign.hs
@@ -201,7 +201,7 @@ peekEncodedCString (TextEncoding { mkTextDecoder = mk_decoder }) (p, sz_bytes)
from0 <- fmap (\fp -> bufferAdd sz_bytes (emptyBuffer fp sz_bytes ReadBuffer)) $ newForeignPtr_ (castPtr p)
to <- newCharBuffer chunk_size WriteBuffer
- let go iteration from = do
+ let go !iteration from = do
(why, from', to') <- encode decoder from to
if isEmptyBuffer from'
then
@@ -230,7 +230,7 @@ withEncodedCString (TextEncoding { mkTextEncoder = mk_encoder }) null_terminate
= bracket mk_encoder close $ \encoder -> withArrayLen s $ \sz p -> do
from <- fmap (\fp -> bufferAdd sz (emptyBuffer fp sz ReadBuffer)) $ newForeignPtr_ p
- let go iteration to_sz_bytes = do
+ let go !iteration to_sz_bytes = do
putDebugMsg ("withEncodedCString: " ++ show iteration)
allocaBytes to_sz_bytes $ \to_p -> do
mb_res <- tryFillBufferAndCall encoder null_terminate from to_p to_sz_bytes act
@@ -250,7 +250,7 @@ newEncodedCString (TextEncoding { mkTextEncoder = mk_encoder }) null_terminate s
= bracket mk_encoder close $ \encoder -> withArrayLen s $ \sz p -> do
from <- fmap (\fp -> bufferAdd sz (emptyBuffer fp sz ReadBuffer)) $ newForeignPtr_ p
- let go iteration to_p to_sz_bytes = do
+ let go !iteration to_p to_sz_bytes = do
putDebugMsg ("newEncodedCString: " ++ show iteration)
mb_res <- tryFillBufferAndCall encoder null_terminate from to_p to_sz_bytes return
case mb_res of
@@ -272,7 +272,7 @@ tryFillBufferAndCall encoder null_terminate from0 to_p to_sz_bytes act = do
to_fp <- newForeignPtr_ to_p
go (0 :: Int) (from0, emptyBuffer to_fp to_sz_bytes WriteBuffer)
where
- go iteration (from, to) = do
+ go !iteration (from, to) = do
(why, from', to') <- encode encoder from to
putDebugMsg ("tryFillBufferAndCall: " ++ show iteration ++ " " ++ show why ++ " " ++ summaryBuffer from ++ " " ++ summaryBuffer from')
if isEmptyBuffer from'