diff options
author | Ruben Bridgewater <ruben@bridgewater.de> | 2017-08-19 02:47:27 -0300 |
---|---|---|
committer | Ruben Bridgewater <ruben@bridgewater.de> | 2017-08-28 23:19:03 -0300 |
commit | 4381100371b6377f2d51d55deeb300a9bc1f39da (patch) | |
tree | c22a44127f20d9aaac8a0c6d23e4daeaace2af9e /lib/assert.js | |
parent | 7854562143ccd3add3f31cc6f4f7ab22ce6582ca (diff) | |
download | android-node-v8-4381100371b6377f2d51d55deeb300a9bc1f39da.tar.gz android-node-v8-4381100371b6377f2d51d55deeb300a9bc1f39da.tar.bz2 android-node-v8-4381100371b6377f2d51d55deeb300a9bc1f39da.zip |
assert: handle sparse arrays in deepStrictEqual
Detect sparse array ends and add a fail early path for
unequal array length.
PR-URL: https://github.com/nodejs/node/pull/15027
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Diffstat (limited to 'lib/assert.js')
-rw-r--r-- | lib/assert.js | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/assert.js b/lib/assert.js index bdc2fcf5a8..70327467ab 100644 --- a/lib/assert.js +++ b/lib/assert.js @@ -180,7 +180,14 @@ function strictDeepEqual(actual, expected) { if (Object.getPrototypeOf(actual) !== Object.getPrototypeOf(expected)) { return false; } - if (isObjectOrArrayTag(actualTag)) { + if (actualTag === '[object Array]') { + // Check for sparse arrays and general fast path + if (actual.length !== expected.length) + return false; + // Skip testing the part below and continue in the callee function. + return; + } + if (actualTag === '[object Object]') { // Skip testing the part below and continue in the callee function. return; } |