rearrange filewalker filter checks to optimize regexp calls (#2780)