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 authored and JeffBezanson committed Jul 26, 2018
1 parent 0f8c0bb commit 9e7ae17
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions base/io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -842,13 +842,12 @@ 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)
new{typeof(stream)}(stream, ondone, keep)
end

"""
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 9e7ae17

Please sign in to comment.