Autocomplete: Optimize element type checks for speed and size.