you would have to do this millions of times per tick for it to be a performance bottleneck. none of those operations are expensive. I haven’t tested the performance of this, but i bet its faster than finding the length of a vector. just because a formula takes 3 lines to write doesn’t mean its expensive for a computer to run.
i recommend using whatever method you think will make it easiest for humans to read, and worry about performance when it really counts. the 27 if statements might be easier to read, and might be a fraction of a millisecond faster, but it doesn’t solve the general problem of using a switch case to evaluate multiple states at once.
this may not be the best example, but knowing how to compress multiple values into a single value, which still contains all the information you need, is usually more valuable for saving memory or bandwidth, rather than speeding things up.