Important observation: because the hot loops
constraint.letter ∉ word
constraint.letter ∈ word
seem to be way faster for Vector{Char}
than for String
. Quick example
julia> x = "salet"
"salet"
julia> @btime in('t', $x)
14.930 ns (0 allocations: 0 bytes)
true
julia> x = Vector{Char}("salet")
5-element Vector{Char}:
's': ASCII/Unicode U+0073 (category Ll: Letter, lowercase)
'a': ASCII/Unicode U+0061 (category Ll: Letter, lowercase)
'l': ASCII/Unicode U+006C (category Ll: Letter, lowercase)
'e': ASCII/Unicode U+0065 (category Ll: Letter, lowercase)
't': ASCII/Unicode U+0074 (category Ll: Letter, lowercase)
julia> @btime in('t', $x)
3.200 ns (0 allocations: 0 bytes)
true