Skip to content

Commit 475e7b3

Browse files
committed
some random optimizations
Hopefully…
1 parent 54b1a5a commit 475e7b3

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

debug.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,10 @@ function debug(namespace) {
8383
if (null == self.useColors) self.useColors = exports.useColors();
8484
if (null == self.color && self.useColors) self.color = selectColor();
8585

86-
var args = Array.prototype.slice.call(arguments);
86+
var args = new Array(arguments.length);
87+
for (var i = 0; i < args.length; i++) {
88+
args[i] = arguments[i];
89+
}
8790

8891
args[0] = exports.coerce(args[0]);
8992

@@ -110,9 +113,9 @@ function debug(namespace) {
110113
return match;
111114
});
112115

113-
if ('function' === typeof exports.formatArgs) {
114-
args = exports.formatArgs.apply(self, args);
115-
}
116+
// apply env-specific formatting
117+
args = exports.formatArgs.apply(self, args);
118+
116119
var logFn = enabled.log || exports.log || console.log.bind(console);
117120
logFn.apply(self, args);
118121
}

node.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,12 @@ exports.formatters.o = exports.formatters.O = function(v) {
8080
*/
8181

8282
function formatArgs() {
83-
var args = [];
8483
var len = arguments.length;
84+
var args = new Array(len);
8585
var useColors = this.useColors;
8686
var name = this.namespace;
8787
for (var i = 0; i < len; i++) {
88-
args.push(arguments[i]);
88+
args[i] = arguments[i];
8989
}
9090

9191
if (useColors) {

0 commit comments

Comments
 (0)