Optimize PathLimit calculation.