GeezerVison is showing github.com — util: remove unreachable defensive coding · nodejs/node@bff201a
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: lib/internal/util/comparisons.js +3-42Lines changed: 3 additions & 42 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -44,15 +44,6 @@ const { | 44 | 44 | isSymbolObject, | 45 | 45 | isFloat32Array, | 46 | 46 | isFloat64Array, | 47 | | - isUint8Array, | 48 | | - isUint8ClampedArray, | 49 | | - isUint16Array, | 50 | | - isUint32Array, | 51 | | - isInt8Array, | 52 | | - isInt16Array, | 53 | | - isInt32Array, | 54 | | - isBigInt64Array, | 55 | | - isBigUint64Array | 56 | 47 | } = types; | 57 | 48 | const { | 58 | 49 | getOwnNonIndexProperties, | @@ -126,38 +117,6 @@ function isEqualBoxedPrimitive(val1, val2) { | 126 | 117 | assert.fail(`Unknown boxed type ${val1}`); | 127 | 118 | } | 128 | 119 |
| 129 | | -function isIdenticalTypedArrayType(a, b) { | 130 | | - // Fast path to reduce type checks in the common case. | 131 | | - const check = types[`is${TypedArrayPrototypeGetSymbolToStringTag(a)}`]; | 132 | | - if (check !== undefined && check(a)) { | 133 | | - return check(b); | 134 | | - } | 135 | | - // Manipulated Symbol.toStringTag. | 136 | | - for (const check of [ | 137 | | - isUint16Array, | 138 | | - isUint32Array, | 139 | | - isInt8Array, | 140 | | - isInt16Array, | 141 | | - isInt32Array, | 142 | | - isFloat32Array, | 143 | | - isFloat64Array, | 144 | | - isBigInt64Array, | 145 | | - isBigUint64Array, | 146 | | - isUint8ClampedArray, | 147 | | - isUint8Array | 148 | | - ]) { | 149 | | - if (check(a)) { | 150 | | - return check(b); | 151 | | - } | 152 | | - } | 153 | | - /* c8 ignore next 4 */ | 154 | | - assert.fail( | 155 | | - 'Unknown TypedArray type checking ' + | 156 | | - `${TypedArrayPrototypeGetSymbolToStringTag(a)} ${a}\n` + | 157 | | - `and ${TypedArrayPrototypeGetSymbolToStringTag(b)} ${b}` | 158 | | - ); | 159 | | -} | 160 | | - | 161 | 120 | // Notes: Type tags are historical [[Class]] properties that can be set by | 162 | 121 | // FunctionTemplate::SetClassName() in C++ or Symbol.toStringTag in JS | 163 | 122 | // and retrieved using Object.prototype.toString.call(obj) in JS | @@ -241,8 +200,10 @@ function innerDeepEqual(val1, val2, strict, memos) { | 241 | 200 | return false; | 242 | 201 | } | 243 | 202 | } else if (isArrayBufferView(val1)) { | 244 | | - if (!isIdenticalTypedArrayType(val1, val2)) | | 203 | + if (TypedArrayPrototypeGetSymbolToStringTag(val1) !== | | 204 | + TypedArrayPrototypeGetSymbolToStringTag(val2)) { | 245 | 205 | return false; | | 206 | + } | 246 | 207 | if (!strict && (isFloat32Array(val1) || isFloat64Array(val1))) { | 247 | 208 | if (!areSimilarFloatArrays(val1, val2)) { | 248 | 209 | return false; | |
|