Skip to content

Commit

Permalink
use a type parameter for stream in EachLine, improves performance
Browse files Browse the repository at this point in the history
  • Loading branch information
KristofferC committed Jul 24, 2018
1 parent e6f5098 commit a646584
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions base/io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -842,14 +842,13 @@ read(s::IO, T::Type) = error("The IO stream does not support reading objects of

## high-level iterator interfaces ##

struct EachLine
stream::IO
struct EachLine{IOT <: IO}
stream::IOT
ondone::Function
keep::Bool

EachLine(stream::IO=stdin; ondone::Function=()->nothing, keep::Bool=false) =
new(stream, ondone, keep)
end
EachLine(stream::IO=stdin; ondone::Function=()->nothing, keep::Bool=false) =
EachLine(stream, ondone, keep)

"""
eachline(io::IO=stdin; keep::Bool=false)
Expand Down Expand Up @@ -898,9 +897,9 @@ function iterate(itr::EachLine, state=nothing)
(readline(itr.stream, keep=itr.keep), nothing)
end

eltype(::Type{EachLine}) = String
eltype(::Type{<:EachLine}) = String

IteratorSize(::Type{EachLine}) = SizeUnknown()
IteratorSize(::Type{<:EachLine}) = SizeUnknown()

# IOStream Marking
# Note that these functions expect that io.mark exists for
Expand Down

0 comments on commit a646584

Please sign in to comment.