Is this the best way to read rotary encoder?

Why? What is this extreme optimization for?

If this is a high speed shaft encoder that is giving you kiloHertz pulses and the ISR is using an unacceptable amount of your CPU time then this may be a good idea. If it is a knob turned by hand then use Paul Stoffregen's Encoder library. It is already highly optimized for all the major Arduino architectures.

This code is highly non-portable. It is difficult even to change pins. When you find that you need to change to a different Arduino for any reason then you have to come back here and fix this part.

Skipping every second transition by only interrupting on one of the two pins is a valid optimization if you don't need the resolution and you don't have enough interrupt pins. Many knob encoders will work well with this because they have two electrical transitions between each mechanical detent. But some won't. Do you know which type you have?