Skip to content

Commit eac77de

Browse files
TotalVerbtkelman
authored andcommitted
Unrevert #18259 (#18280)
* Revert "Revert #182599 "add faster done for strings" (#18275)" This reverts commit 6d179b3. * Test that next(s, endof(s)) > endof(s.data) (cherry picked from commit 62c3bfa)
1 parent 060016a commit eac77de

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

base/strings/string.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ end
8080
return Char(c), i
8181
end
8282

83+
# This implementation relies on `next` returning a value past the end of the
84+
# String's underlying data, which is true for valid Strings
85+
done(s::String, state) = state > endof(s.data)
86+
8387
@inline function next(s::String, i::Int)
8488
# function is split into this critical fast-path
8589
# for pure ascii data, such as parsing numbers,

test/strings/basic.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,3 +427,9 @@ foobaz(ch) = reinterpret(Char, typemax(UInt32))
427427

428428
# issue #17624, missing getindex method for String
429429
@test "abc"[:] == "abc"
430+
431+
# issue #18280: next/nextind must return past String's underlying data
432+
for s in ("Hello", "Σ", "こんにちは", "😊😁")
433+
@test next(s, endof(s))[2] > endof(s.data)
434+
@test nextind(s, endof(s)) > endof(s.data)
435+
end

0 commit comments

Comments
 (0)