Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit bff201a

Browse filesBrowse files
Trottdanielleadams
authored andcommitted
util: remove unreachable defensive coding
Now that we are using primordials in the first part of isIdenticalTypedArrayType(), the defensive coding to get the correct result (when Symbol.toStringTag is manipulated) is no longer reachable or necessary. Remove the code. Refs: https://coverage.nodejs.org/coverage-873d21cdc1266273/lib/internal/util/comparisons.js.html#L135 PR-URL: #36744 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent 8f672eb commit bff201a
Copy full SHA for bff201a

File tree

Expand file treeCollapse file tree

1 file changed

+3
-42
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+3
-42
lines changed
Open diff view settings
Collapse file

‎lib/internal/util/comparisons.js‎

Copy file name to clipboardExpand all lines: lib/internal/util/comparisons.js
+3-42Lines changed: 3 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,6 @@ const {
4444
isSymbolObject,
4545
isFloat32Array,
4646
isFloat64Array,
47-
isUint8Array,
48-
isUint8ClampedArray,
49-
isUint16Array,
50-
isUint32Array,
51-
isInt8Array,
52-
isInt16Array,
53-
isInt32Array,
54-
isBigInt64Array,
55-
isBigUint64Array
5647
} = types;
5748
const {
5849
getOwnNonIndexProperties,
@@ -126,38 +117,6 @@ function isEqualBoxedPrimitive(val1, val2) {
126117
assert.fail(`Unknown boxed type ${val1}`);
127118
}
128119

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-
161120
// Notes: Type tags are historical [[Class]] properties that can be set by
162121
// FunctionTemplate::SetClassName() in C++ or Symbol.toStringTag in JS
163122
// and retrieved using Object.prototype.toString.call(obj) in JS
@@ -241,8 +200,10 @@ function innerDeepEqual(val1, val2, strict, memos) {
241200
return false;
242201
}
243202
} else if (isArrayBufferView(val1)) {
244-
if (!isIdenticalTypedArrayType(val1, val2))
203+
if (TypedArrayPrototypeGetSymbolToStringTag(val1) !==
204+
TypedArrayPrototypeGetSymbolToStringTag(val2)) {
245205
return false;
206+
}
246207
if (!strict && (isFloat32Array(val1) || isFloat64Array(val1))) {
247208
if (!areSimilarFloatArrays(val1, val2)) {
248209
return false;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.