From 2a77dba66510afd5b642f85d04ca6851436683f0 Mon Sep 17 00:00:00 2001 From: Stefan Karpinski Date: Sat, 11 Jun 2016 19:56:48 -0400 Subject: [PATCH] Manually hoist conversion of end-of-line character to UInt8 In some confiurations LLVM doesn't seem to do this optimization Fix #16822 --- base/datafmt.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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