diff --git a/lib/internal/util/comparisons.js b/lib/internal/util/comparisons.js index 0bc46257e829fc..ed8ddf6ad321d8 100644 --- a/lib/internal/util/comparisons.js +++ b/lib/internal/util/comparisons.js @@ -44,15 +44,6 @@ const { isSymbolObject, isFloat32Array, isFloat64Array, - isUint8Array, - isUint8ClampedArray, - isUint16Array, - isUint32Array, - isInt8Array, - isInt16Array, - isInt32Array, - isBigInt64Array, - isBigUint64Array } = types; const { getOwnNonIndexProperties, @@ -126,38 +117,6 @@ function isEqualBoxedPrimitive(val1, val2) { assert.fail(`Unknown boxed type ${val1}`); } -function isIdenticalTypedArrayType(a, b) { - // Fast path to reduce type checks in the common case. - const check = types[`is${TypedArrayPrototypeGetSymbolToStringTag(a)}`]; - if (check !== undefined && check(a)) { - return check(b); - } - // Manipulated Symbol.toStringTag. - for (const check of [ - isUint16Array, - isUint32Array, - isInt8Array, - isInt16Array, - isInt32Array, - isFloat32Array, - isFloat64Array, - isBigInt64Array, - isBigUint64Array, - isUint8ClampedArray, - isUint8Array - ]) { - if (check(a)) { - return check(b); - } - } - /* c8 ignore next 4 */ - assert.fail( - 'Unknown TypedArray type checking ' + - `${TypedArrayPrototypeGetSymbolToStringTag(a)} ${a}\n` + - `and ${TypedArrayPrototypeGetSymbolToStringTag(b)} ${b}` - ); -} - // Notes: Type tags are historical [[Class]] properties that can be set by // FunctionTemplate::SetClassName() in C++ or Symbol.toStringTag in JS // and retrieved using Object.prototype.toString.call(obj) in JS @@ -241,8 +200,10 @@ function innerDeepEqual(val1, val2, strict, memos) { return false; } } else if (isArrayBufferView(val1)) { - if (!isIdenticalTypedArrayType(val1, val2)) + if (TypedArrayPrototypeGetSymbolToStringTag(val1) !== + TypedArrayPrototypeGetSymbolToStringTag(val2)) { return false; + } if (!strict && (isFloat32Array(val1) || isFloat64Array(val1))) { if (!areSimilarFloatArrays(val1, val2)) { return false;