mirror of
https://github.com/nodejs/node.git
synced 2026-10-14 10:26:26 -04:00
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:
1 file changed
+5
@@ -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]',
|
||||
|
||||
Reference in new issue
Block a user