2 ms·
julia> using Random, BenchmarkTools julia> function isvowel(c) idx = (c | 0x20) - Int('a') return (0x00104111 & (1 << idx)) != 0
by fedsocpuppet 1y ago
julia> using Random, BenchmarkTools
julia> function isvowel(c)
idx = (c | 0x20) - Int('a')
return (0x00104111 & (1 << idx)) != 0
end
julia> hasvowel(str) = any(c -> isvowel(Int(c)), str)
julia> @btime hasvowel(s) setup=(s=randstring("bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ0123456789", 10))
15.739 ns (0 allocations: 0 bytes)
false
some 77 thousand times faster