Skip to content

Commit

Permalink
Further improvements to console stubbing method
Browse files Browse the repository at this point in the history
These improvements are:

- cache current method in `while`-loop to reduce property look-ups
- use `if` as the conditional assignment in `while`-loop in order to improve performance and readability

Reference: commit 578f377
Closes gh-1229
  • Loading branch information
drublic committed Oct 14, 2012
1 parent dc00673 commit b2ab421
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion js/plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@
var console = (window.console = window.console || {});

while (length--) {
var method = methods[length];

This comment has been minimized.

Copy link
@necolas

necolas Oct 14, 2012

Member

Should probably move the var declaration itself outside of the loop.

This comment has been minimized.

Copy link
@drublic

drublic Oct 14, 2012

Author Member

Fixed with 750bf0e.


// Only stub undefined methods.
console[methods[length]] = console[methods[length]] || noop;
if (!console[method]) {
console[method] = noop;
}
}
}());

Expand Down

0 comments on commit b2ab421

Please sign in to comment.