Skip to content

Commit

Permalink
Improve code to avoid reliance on computation of length
Browse files Browse the repository at this point in the history
The `length` of a String is expensive to compute, and the `length` of a `Stateful` is deprecated. It does not appear to be necessary to compute however.
  • Loading branch information
vtjnash authored Feb 1, 2024
1 parent a1d330c commit 460402e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,8 @@ else
if c === 'x' || c === 'u' || c === 'U'
maxiter = c === 'x' ? 2 : c === 'u' ? 4 : 8
n = 0
for _ in 1:min(length(a), maxiter)
for _ in 1:maxiter
isempty(a) && break
nc = popfirst!(a)
n = '0' <= nc <= '9' ? n << 4 + (nc - '0') :
'a' <= nc <= 'f' ? n << 4 + (nc - 'a' + 10) :
Expand All @@ -564,7 +565,8 @@ else
ok = n <= 0x10ffff
elseif '0' <= c <= '7'
n = c - '0'
for _ in 1:min(length(a), 3)
for _ in 1:3
isempty(a) && break
nc = popfirst!(a)
n = ('0' <= c <= '7') ? n << 3 + nc - '0' : return false
end
Expand Down

0 comments on commit 460402e

Please # to comment.