To shave a few microseconds of the execution time, you could use direct port manipulation to read the pins instead of digitalRead() described, for example, here: Arduino Reference - Arduino Reference.
But, if you are still struggling because of the duration of the activities in the loop, then looks at an example of using interrupts to read an IR sensor. Here is one of many: https://core-electronics.com.au/tutorials/infrared-sensors-arduino.html