Skip to content

Commit

Permalink
Merge pull request #12364 from JuliaLang/sjk/faster-iobuffer-bytes
Browse files Browse the repository at this point in the history
Improve IOBuffer read performance
  • Loading branch information
JeffBezanson committed Jul 29, 2015
2 parents 9163fe0 + d98ea95 commit e63f8a5
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions base/iobuffer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,15 @@ function read_sub{T}(from::AbstractIOBuffer, a::AbstractArray{T}, offs, nel)
return a
end

function read(from::AbstractIOBuffer, ::Type{UInt8})
@inline function read(from::AbstractIOBuffer, ::Type{UInt8})
ptr = from.ptr
size = from.size
from.readable || throw(ArgumentError("read failed, IOBuffer is not readable"))
if from.ptr > from.size
if ptr > size
throw(EOFError())
end
byte = from.data[from.ptr]
from.ptr += 1
@inbounds byte = from.data[ptr]
from.ptr = ptr + 1
return byte
end

Expand Down

0 comments on commit e63f8a5

Please sign in to comment.