Skip to content

Commit 840c3de

Browse files
committed
WIP: Address some reviewer comments
1 parent 52f60cd commit 840c3de

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

base/iobuffer.jl

+2-3
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,7 @@ function unsafe_write(to::GenericIOBuffer, p::Ptr{UInt8}, nb::UInt)
775775
append = to.append
776776
ptr = append ? size+1 : to.ptr
777777
data = to.data
778-
to_write = min(nb % Int, min(Int(length(data))::Int, to.maxsize) - ptr + 1)
778+
to_write = min(nb, (min(Int(length(data))::Int, to.maxsize) - ptr + 1) % UInt) % Int
779779
# Dispatch based on the type of data, to possibly allow using memcpy
780780
_unsafe_write(data, p, ptr, to_write % UInt)
781781
# Update to.size only if the ptr has advanced to higher than
@@ -850,8 +850,7 @@ readavailable(io::GenericIOBuffer) = read(io)
850850
read(io::GenericIOBuffer, nb::Integer) = read!(io, StringVector(min(nb, bytesavailable(io))))
851851

852852
function occursin(delim::UInt8, buf::GenericIOBuffer)
853-
ptr = buf.ptr
854-
return in(delim, view(buf.data, ptr:ptr + bytesavailable(buf)-1))
853+
return in(delim, view(buf.data, buf.ptr:buf.size))
855854
end
856855

857856
function copyuntil(out::IO, io::GenericIOBuffer, delim::UInt8; keep::Bool=false)

base/stream.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@ end
615615
## BUFFER ##
616616
## Allocate space in buffer (for immediate use)
617617
function alloc_request(buffer::IOBuffer, recommended_size::UInt)
618-
ensureroom(buffer, Int(recommended_size))
618+
ensureroom(buffer, recommended_size)
619619
ptr = buffer.append ? buffer.size + 1 : buffer.ptr
620620
nb = min(length(buffer.data), buffer.maxsize) - ptr + 1
621621
return (Ptr{Cvoid}(pointer(buffer.data, ptr)), nb)

0 commit comments

Comments
 (0)