push the ifs up and the fors down
Doing so makes branching logic easier to follow and test. It also has a large performance impact as only happen once.
Doing so makes branching logic easier to follow and test. It also has a large performance impact as only happen once.