summaryrefslogtreecommitdiff
path: root/lib/internal/assert
diff options
context:
space:
mode:
authorRuben Bridgewater <ruben@bridgewater.de>2019-03-20 15:48:59 +0100
committerRuben Bridgewater <ruben@bridgewater.de>2019-03-23 02:55:57 +0100
commitafce91219359654b44df29e6ec1b730e2a73a919 (patch)
tree22d8fe9d1204537aac7663f3e672fd20c655dc23 /lib/internal/assert
parentf0f26cedccdb8e5d891bff2949651ea8c3a839c1 (diff)
downloadandroid-node-v8-afce91219359654b44df29e6ec1b730e2a73a919.tar.gz
android-node-v8-afce91219359654b44df29e6ec1b730e2a73a919.tar.bz2
android-node-v8-afce91219359654b44df29e6ec1b730e2a73a919.zip
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>
Diffstat (limited to 'lib/internal/assert')
-rw-r--r--lib/internal/assert/assertion_error.js5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/internal/assert/assertion_error.js b/lib/internal/assert/assertion_error.js
index c8edf13eca..7c9bace378 100644
--- a/lib/internal/assert/assertion_error.js
+++ b/lib/internal/assert/assertion_error.js
@@ -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]',