The "exclusive or" operator (XOR / ^) is the best and fastest sollution,
"Best" ? Give me strength. How obscure do you want to make the code ?
The most readable and understandable solution is
byte pinState = digitalRead(pinNum);
if (pinState == HIGH)
{
pinState = LOW;
}
else
{
pinState = HIGH;
}
digitalWrite(pinNum, pinState);
Of course, this verbose code will be dismissed by experienced programmers who delight in tricks to avoid typing. We should not forget that the compiler will optimise the code so we could end up with the same compiled code for several different source code solutions. The source code is meant to be read and understood by humans whilst the compiled code is meant to be read and understand by the computer.
Fastest solution ?
Use port manipulation for an extra level of obscurity or, of course, write the whole thing in assembler for extra points