Skip to content

Commit 4f0bdac

Browse files
committed
Final polish
Drop the `copy` variable, we hava `avail <= nullFree` so copy was just `avail`.
1 parent 55cd1c7 commit 4f0bdac

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

Data/ByteString/Builder/Internal.hs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -919,13 +919,15 @@ cstringUtf8_step !ip !len !nullAt k (BufferRange op0 ope)
919919
len' = len - nread
920920
nullAt' <- c_strstr ip' (Ptr "\xc0\x80"#)
921921
cstringUtf8_step ip' len' nullAt' k (BufferRange op' ope)
922-
| otherwise = do
923-
let !copy = min avail nullFree
924-
when (copy > 0) (S.memcpy op0 ip copy)
925-
let !op' = op0 `plusPtr` copy
926-
!ip' = ip `plusPtr` copy
927-
len' = len - copy
922+
| avail > 0 = do
923+
-- avail <= nullFree
924+
S.memcpy op0 ip avail
925+
let !op' = op0 `plusPtr` avail
926+
!ip' = ip `plusPtr` avail
927+
len' = len - avail
928928
return $ bufferFull 1 op' (cstringUtf8_step ip' len' nullAt k)
929+
| otherwise =
930+
return $ bufferFull 1 op0 (cstringUtf8_step ip len nullAt k)
929931
where
930932
!avail = ope `minusPtr` op0
931933
!nullFree = nullAt `minusPtr` ip

0 commit comments

Comments
 (0)