Difference in speed?

Hi all.
I need to do an interrupt routine at 13 kHz and want it to be as fast as possible.
In the library TimerOne there is an example with

digitalWrite( 13, !digitalRead( 13 ));

in the interrupt routine.

My question is:
If I use this line of code instead to toggle a pin, is it better?

state=!state;
digitalWrite(13, state);

I am thinking that if you use digitalRead in the routine it may be slower?

Many thanks for answers

regards

If you want fast, use direct port manipulation.
Turns out that to toggle a bit, you can just write a 1 to it:
D13 is PortB, bit 5:

PINB = PINB | 0b00100000;

From 14.1 of the datasheet:

Three I/O memory address locations are allocated for each port, one each for the Data Register – PORTx, Data
Direction Register – DDRx, and the Port Input Pins – PINx. The Port Input Pins I/O location is read only, while the
Data Register and the Data Direction Register are read/write. However, writing a logic one to a bit in the PINx Register,
will result in a toggle in the corresponding bit in the Data Register. In addition, the Pull-up Disable – PUD bit
in MCUCR disables the pull-up function for all pins in all ports when set.

I am not sure of that question, but if you want to test it, you can.
Several ways, but one way is to :
Get the value of micros() when reset startMicros.
Do your test code in a for() loop for say,, 1000 loops.
find the difference between the current micros() and the startMicros.

If the interrupt does nothing else:

void interruptRouting(){
PINB = PINB | 0b00100000;
}

that will take about 12-13uS, fast enough to support your 13 KHz.

Thank you very much for the answers!
I will try your suggested solutions.

Regards

Carl