Skip to content

Commit

Permalink
do not recurse inside unsafeUseAsCString and withBuffer
Browse files Browse the repository at this point in the history
  • Loading branch information
msakai committed May 6, 2021
1 parent b8a126a commit 27b678c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Data/ByteString/Lazy/Encoding/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,15 @@ decodeWith Enc.TextEncoding{ .. } inBufSize outBufSize b = TL.fromChunks $ unsaf
go bbs@(b : bs) buf
| isFullBuffer buf = return (bbs, buf)
| B.null b = go bs buf
| otherwise = do
| otherwise = join $ do
B.unsafeUseAsCString b $ \p -> do
withBuffer buf $ \q -> do
if B.length b <= bufferAvailable buf then do
moveBytes (q `plusPtr` bufR buf) p (B.length b)
go bs buf{ bufR = bufR buf + B.length b }
return $ go bs buf{ bufR = bufR buf + B.length b }
else do
moveBytes (q `plusPtr` bufR buf) p (bufferAvailable buf)
go (B.drop (bufferAvailable buf) b : bs) buf{ bufR = bufR buf + bufferAvailable buf }
return $ go (B.drop (bufferAvailable buf) b : bs) buf{ bufR = bufR buf + bufferAvailable buf }

flushOutBuf :: CharBuffer -> Ptr Word16 -> IO ([T.Text], CharBuffer)
flushOutBuf buf workspace
Expand Down

0 comments on commit 27b678c

Please sign in to comment.