Repository : ssh://darcs.haskell.org//srv/darcs/packages/base On branch : encoding
http://hackage.haskell.org/trac/ghc/changeset/ad261e22ef432c566130b17380d57370da847ce1 >--------------------------------------------------------------- commit ad261e22ef432c566130b17380d57370da847ce1 Author: Max Bolingbroke <[email protected]> Date: Fri May 13 09:18:21 2011 +0100 In peekEncodedCString, use a chunk size based on input buffer size >--------------------------------------------------------------- GHC/Foreign.hs | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/GHC/Foreign.hs b/GHC/Foreign.hs index e285bff..b4c760c 100644 --- a/GHC/Foreign.hs +++ b/GHC/Foreign.hs @@ -162,9 +162,9 @@ peekEncodedCString :: TextEncoding -- ^ Encoding of CString -> IO String -- ^ String in Haskell terms peekEncodedCString (TextEncoding { mkTextDecoder = mk_decoder }) (p, sz_bytes) = bracket mk_decoder close $ \decoder -> do - let cHUNK_SIZE = 4096 -- Decode buffer chunk size in characters + let chunk_size = sz_bytes `max` 1 -- Decode buffer chunk size in characters: one iteration only for ASCII from0 <- fmap (\fp -> bufferAdd sz_bytes (emptyBuffer fp sz_bytes ReadBuffer)) $ newForeignPtr_ (castPtr p) - to <- newCharBuffer cHUNK_SIZE WriteBuffer + to <- newCharBuffer chunk_size WriteBuffer let go iteration from = do (why, from', to') <- encode decoder from to _______________________________________________ Cvs-libraries mailing list [email protected] http://www.haskell.org/mailman/listinfo/cvs-libraries
