diff --git a/base/datafmt.jl b/base/datafmt.jl index 365db0559e8be..a031fc851e64d 100644 --- a/base/datafmt.jl +++ b/base/datafmt.jl @@ -18,12 +18,13 @@ const offs_chunk_size = 5000 countlines(f::AbstractString, eol::Char='\n') = open(io->countlines(io,eol), f)::Int function countlines(io::IO, eol::Char='\n') isascii(eol) || throw(ArgumentError("only ASCII line terminators are supported")) + aeol = UInt8(eol) a = Array{UInt8}(8192) nl = 0 while !eof(io) nb = readbytes!(io, a) @simd for i=1:nb - @inbounds nl += a[i] == UInt8(eol) + @inbounds nl += a[i] == aeol end end nl