Micro-optimize get_proper_type(s) (#14369)
These are used a lot, so it makes sense to tune them a bit. We now avoid
allocations in a common case, when compiled.
(Various small optimizations, including these, together netted a 6%
performance improvement in self check.)