Switching an Output to opposite to last status

fiddler:
I use the onboard LED on pin 13 as a simple visual monitor, to see that, 1; the program is running and 2; how fast the it get around the loop.

So I have a function like this:

void HeartBeat(void)
{
if (HeartBeatState>0) {
digitalWrite(13,HIGH);
HeartBeatState= 0;
}
else{
digitalWrite(13,LOW);
HeartBeatState= 1;
}
return;

Is there a way to use XOR on the output ?

I guess my question really is: What is the fastest way of switching an output pin ?

Cheers

K

I remember time ago someone asking for a DigitalWrite(TOGGLE); but I think it was never added. You can however use something like this:

boolean s;
void HeartBeat()
{
   digitalWrite(13,s=!s);
}