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

Manually split string(a::Union{Char, String, SubString{String}, Symbol}...) #43939

Merged
merged 2 commits into from
Jan 26, 2022
Merged
Changes from all commits
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
8 changes: 7 additions & 1 deletion base/strings/substring.jl
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,16 @@ end
function string(a::Union{Char, String, SubString{String}, Symbol}...)
n = 0
for v in a
# 4 types is too many for automatic Union-splitting, so we split manually
# and allow one specializable call site per concrete type
if v isa Char
n += ncodeunits(v)
else
elseif v isa String
n += sizeof(v)
elseif v isa SubString{String}
n += sizeof(v)
else
n += sizeof(v::Symbol)
end
end
out = _string_n(n)
Expand Down