Skip to content

Commit 2119ea6

Browse files
Manually hoist conversion of end-of-line character to UInt8 (#16886)
In some confiurations LLVM doesn't seem to do this optimization Fix #16822
1 parent a84f702 commit 2119ea6

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

base/datafmt.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,13 @@ const offs_chunk_size = 5000
1818
countlines(f::AbstractString, eol::Char='\n') = open(io->countlines(io,eol), f)::Int
1919
function countlines(io::IO, eol::Char='\n')
2020
isascii(eol) || throw(ArgumentError("only ASCII line terminators are supported"))
21+
aeol = UInt8(eol)
2122
a = Array{UInt8}(8192)
2223
nl = 0
2324
while !eof(io)
2425
nb = readbytes!(io, a)
2526
@simd for i=1:nb
26-
@inbounds nl += a[i] == UInt8(eol)
27+
@inbounds nl += a[i] == aeol
2728
end
2829
end
2930
nl

0 commit comments

Comments
 (0)