[EDIT: you can ignore A. it was kind of a false alarm. B. is still a little interesting to me, in general, maybe not in the case of A. though.]
A.
I thought I would/could optimize uppercase (and others, I found in [PR] Julia standard library…):
First I tried changing to:
uppercase(c::Char) = isascii(c) ? ('a' <= c <= 'z' ? c | 0x20 : c) : Char(ccall(:utf8proc_toupper, UInt32, (UInt32,), c))
@code_native new_uppercase('p') # much longer, than original below in PR
Minimal code doesn’t help for xor unlike or:
@inline new_uppercase(c) = xor(c, 0x20) # this is still long/slow, but not with *or*, c | 0x20 # operators shouldn't be faster as just syntatic sugar?
@code_native new_uppercase(2)
https://github.com/JuliaLang/julia/pull/19469/files
lowercase(c::Char) = isascii(c) ? ('A' <= c <= 'Z' ? c + 0x20 : c) : Char(ccall(:utf8proc_tolower, UInt32, (UInt32,), c))
uppercase(c::Char) = isascii(c) ? ('a' <= c <= 'z' ? c - 0x20 : c) : Char(ccall(:utf8proc_toupper, UInt32, (UInt32,), c))
titlecase(c::Char) = isascii(c) ? ('a' <= c <= 'z' ? c - 0x20 : c) : Char(ccall(:utf8proc_totitle, UInt32, (UInt32,), c))
B.
For strings, not Char literals, should map be able to inline uppercase?:
new_uppercase(s::AbstractString) = @inbounds map(new_uppercase, s)