Skip to content

Commit 38cb373

Browse files
committed
Make skipcharsets non-allocating
It needed a little tweaking for constant-propagation to work.
1 parent cd6a3f3 commit 38cb373

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/lexer.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,7 @@ julia> skipcharsets(strv, 1, 'a':'z', '0':'9', ' ', '.', '-')
760760
12
761761
```
762762
"""
763-
function skipcharsets(bytes::DenseVector{UInt8}, pos::Integer, charsets::Union{StepRange{Char}, Char}...; limit::Integer = length(bytes) % typeof(pos))
763+
function skipcharsets(bytes::DenseVector{UInt8}, pos::Integer, charsets::NTuple{N, Union{StepRange{Char}, Char}}; limit::Integer = length(bytes) % typeof(pos)) where {N}
764764
skipranges = map(c -> if c isa Char UInt8(c) else
765765
UInt8(first(c)):UInt8(last(c)) end,
766766
charsets)
@@ -773,6 +773,9 @@ function skipcharsets(bytes::DenseVector{UInt8}, pos::Integer, charsets::Union{S
773773
next
774774
end
775775

776+
skipcharsets(bytes::DenseVector{UInt8}, pos::Integer, charsets::Union{StepRange{Char}, Char}...; limit::Integer = length(bytes) % typeof(pos)) =
777+
skipcharsets(bytes, pos, Tuple(charsets); limit)
778+
776779
"""
777780
skipbalanced(bytes::DenseVector{UInt8}, pos::Integer, bpair::Pair{Char, Char},
778781
quotes::NTuple{N, Char} = (), escapechar::Union{Char, Nothing} = nothing) -> Integer

0 commit comments

Comments
 (0)