Skip to content

Commit 403920e

Browse files
authored
miro-optimize iterate on string (#35838)
1 parent 4562ece commit 403920e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

base/strings/string.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,9 @@ is_valid_continuation(c) = c & 0xc0 == 0x80
176176

177177
## required core functionality ##
178178

179-
@propagate_inbounds function iterate(s::String, i::Int=firstindex(s))
180-
i > ncodeunits(s) && return nothing
181-
b = codeunit(s, i)
179+
@inline function iterate(s::String, i::Int=firstindex(s))
180+
(i % UInt) - 1 < ncodeunits(s) || return nothing
181+
b = @inbounds codeunit(s, i)
182182
u = UInt32(b) << 24
183183
between(b, 0x80, 0xf7) || return reinterpret(Char, u), i+1
184184
return iterate_continued(s, i, u)

0 commit comments

Comments
 (0)