loop/conditional optimizations

Uncertainty on whether line 1743 (original)/1782 (new) is actually supposed to be like that. Please comment here on whether or not it is a bug that should be patched here as well.

Code has been profiled and tested as equivalent. It also is somewhat faster, as profiled in the V8 engine (tested using the minified release of jQuery 2.1.1). Out of 30 reps, it was 73 milliseconds faster.