Skip to content

Commit 816f98f

Browse files
BridgeARaddaleax
authored andcommittedJul 18, 2017
console: use a plain object for the the error stack
Using a object instead of an Error is sufficient as the Error itself won't be used but only the stack trace that would otherwise be created twice. This improves the overall .trace() performance. PR-URL: #13743 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Timothy Gu <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Refael Ackermann <[email protected]>
1 parent 04bca73 commit 816f98f

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed
 

‎lib/console.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,10 @@ Console.prototype.timeEnd = function timeEnd(label) {
150150

151151

152152
Console.prototype.trace = function trace(...args) {
153-
// TODO probably can to do this better with V8's debug object once that is
154-
// exposed.
155-
var err = new Error();
156-
err.name = 'Trace';
157-
err.message = util.format.apply(null, args);
153+
const err = {
154+
name: 'Trace',
155+
message: util.format.apply(null, args)
156+
};
158157
Error.captureStackTrace(err, trace);
159158
this.error(err.stack);
160159
};

0 commit comments

Comments
 (0)
Please sign in to comment.