|
|
|
|
|
by fedsocpuppet
370 days 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 |
|