Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement fast isascii for String #30400

Merged
merged 3 commits into from
Feb 14, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
use a loop
  • Loading branch information
KristofferC committed Dec 20, 2018
commit 198f5002d49b8313c5358136ec634060bc50ca07
7 changes: 6 additions & 1 deletion base/strings/string.jl
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,12 @@ end

isvalid(s::String, i::Int) = checkbounds(Bool, s, i) && thisind(s, i) == i

isascii(s::String) = all(i -> @inbounds(codeunit(s, i)) < 0x80, 1:sizeof(s))
function isascii(s::String)
@inbounds for i = 1:ncodeunits(s)
codeunit(s, i) >= 0x80 && return false
end
return true
end

"""
repeat(c::AbstractChar, r::Integer) -> String
Expand Down