Converting ASCII to hex

arusr:
I'm trying to convert a ascii representation of a mac address like 1122334455667788 to eight bytes of hex that represents the same mac address.

char text[] = "1122334455667788";
char hex[8];

void foo() {
  for (int i = 0; i < 8; i++) {
    hex[i] = (toHex(text[i * 2]) << 8) | toHex(text[i * 2 + 1]);
  }
}
inline byte toHex(char z) {
  return z <= '9' ? z - '0' :  z <= 'F' ? z - 'A' + 10 : z - 'a' + 10;
}