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:
Ruben Bridgewater authored and Refael Ackermann committed 2017-07-09 14:16:34 -04:00
1 parent 4d7946aec3
commit be20e9ecfe
3 files changed
+199 -203

No files matched your search

+1 -3
View File
@@ -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);
}
}