Skip to content

Commit 74b868d

Browse files
committed
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.
1 parent 1d91556 commit 74b868d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/raven.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -642,8 +642,8 @@ function isSetup() {
642642
function joinRegExp(patterns) {
643643
// Combine an array of regular expressions and strings into one large regexp
644644
// Be mad.
645-
var sources = [];
646-
for (var i = 0; i < patterns.length; i++) {
645+
var sources = [], len = patterns.length;
646+
for (var i = 0; i < len; i++) {
647647
if (isString(patterns[i])) {
648648
// If it's a string, we need to escape it
649649
// Taken from: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions

0 commit comments

Comments
 (0)