Arduino nano, but faster

In general, digitalRead() and digitalWrite() are notoriously slow. But, they provide a consistent interface to hardware regardless of processor type. This is one of the strengths of the Arduino platform but of course any strength is also a weakness.

You can speed up I/O routines significantly by using direct hardware port reads and writes using the predefined DDRn PORTn PINn registers. The strength is speed, the weakness is the loss of processor/board portability.

Fortunately, the Uno and Nano use the same ATmega328 processor so it’s not an issue for those two boards and what you’re doing now, but it would require a rewrite to use the code on a Mega (ATmega2561) or even worse, a non-AVR part like a Due or Zero.