Switch return type of pass_doors_optimized() from list to generator for further optimization.