mirror of https://github.com/nodejs/node.git
assert: improve performance to instantiate errors
This improves the performance for AssertionError by deactivating duplicated stack frame creation. PR-URL: https://github.com/nodejs/node/pull/26738 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
This commit is contained in:
parent
f0f26cedcc
commit
afce912193
|
@ -300,6 +300,9 @@ class AssertionError extends Error {
|
|||
stackStartFn
|
||||
} = options;
|
||||
|
||||
const limit = Error.stackTraceLimit;
|
||||
Error.stackTraceLimit = 0;
|
||||
|
||||
if (message != null) {
|
||||
super(String(message));
|
||||
} else {
|
||||
|
@ -387,6 +390,8 @@ class AssertionError extends Error {
|
|||
}
|
||||
}
|
||||
|
||||
Error.stackTraceLimit = limit;
|
||||
|
||||
this.generatedMessage = !message;
|
||||
Object.defineProperty(this, 'name', {
|
||||
value: 'AssertionError [ERR_ASSERTION]',
|
||||
|
|
Loading…
Reference in New Issue