Cache the value of patterns.length outside the for loop

Likely
[benefits](http://stackoverflow.com/questions/6261953/do-modern-javascript-jiters-need-array-length-caching-in-loops)
the performance of older browsers that lack smart caching.

Thanks again to @soundslocke for the heads up.