mirror of
https://github.com/nodejs/node.git
synced 2026-10-14 10:26:26 -04:00
assert: refactor to reduce unecessary code paths
The lazy loading is not needed as the errors themself lazy load assert. Therefore the circle is working as intended even without this lazy loading. Improve Array, object, ArrayBuffer, Set and Map performance in all deepEqual checks by removing unecessary code paths and by moving expensive checks further back. Improve throws and doesNotThrow performance by removing dead code and simplifying the overall logic. PR-URL: https://github.com/nodejs/node/pull/13973 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
This commit is contained in:
1 parent
4d7946aec3
commit
be20e9ecfe
3 files changed
+199
-203
No files matched your search
@@ -46,7 +46,6 @@ class AssertionError extends Error {
|
||||
throw new exports.TypeError('ERR_INVALID_ARG_TYPE', 'options', 'object');
|
||||
}
|
||||
const util = lazyUtil();
|
||||
const assert = lazyAssert();
|
||||
const message = options.message ||
|
||||
`${util.inspect(options.actual).slice(0, 128)} ` +
|
||||
`${options.operator} ` +
|
||||
@@ -59,8 +58,7 @@ class AssertionError extends Error {
|
||||
this.actual = options.actual;
|
||||
this.expected = options.expected;
|
||||
this.operator = options.operator;
|
||||
const stackStartFunction = options.stackStartFunction || assert.fail;
|
||||
Error.captureStackTrace(this, stackStartFunction);
|
||||
Error.captureStackTrace(this, options.stackStartFunction);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user