Skip to content

Commit 27a2adc

Browse files
BridgeARaddaleax
authored andcommitted
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 <luigipinca@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
1 parent d9a1f70 commit 27a2adc

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

lib/console.js

Lines changed: 4 additions & 5 deletions
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)