Skip to content

Commit 70b31ad

Browse files
BridgeARrefack
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 <[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 3e17884 commit 70b31ad

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
@@ -151,11 +151,10 @@ Console.prototype.timeEnd = function timeEnd(label) {
151151

152152

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

0 commit comments

Comments
 (0)