Skip to content

Commit

Permalink
Merge pull request #21444 from JuliaLang/jb/readstring_perf
Browse files Browse the repository at this point in the history
avoid an extra copy in some cases of `readstring`
  • Loading branch information
JeffBezanson committed Apr 20, 2017
2 parents 8a3b6c1 + e3dae81 commit a58e8f0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion base/iobuffer.jl
Expand Up @@ -75,7 +75,7 @@ optionally specifying a size beyond which the underlying `Array` may not be grow
"""
PipeBuffer(data::Vector{UInt8}=UInt8[], maxsize::Int=typemax(Int)) =
AbstractIOBuffer(data,true,true,false,true,maxsize)
PipeBuffer(maxsize::Int) = (x = PipeBuffer(Vector{UInt8}(maxsize),maxsize); x.size=0; x)
PipeBuffer(maxsize::Int) = (x = PipeBuffer(StringVector(maxsize),maxsize); x.size=0; x)

function copy(b::AbstractIOBuffer)
ret = typeof(b)(b.writable ? copy(b.data) : b.data,
Expand Down
2 changes: 1 addition & 1 deletion base/iostream.jl
Expand Up @@ -287,7 +287,7 @@ function read(s::IOStream)
sz -= pos
end
end
b = Array{UInt8,1}(sz<=0 ? 1024 : sz)
b = StringVector(sz<=0 ? 1024 : sz)
nr = readbytes_all!(s, b, typemax(Int))
resize!(b, nr)
end
Expand Down

0 comments on commit a58e8f0

Please sign in to comment.