Skip to content

Commit 2e50acf

Browse files
authored
perf(runtime-core): optimize the performance of getTypeIndex (#3206)
1 parent c8df618 commit 2e50acf

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

packages/runtime-core/src/componentProps.ts

+1-5
Original file line numberDiff line numberDiff line change
@@ -456,11 +456,7 @@ function getTypeIndex(
456456
expectedTypes: PropType<any> | void | null | true
457457
): number {
458458
if (isArray(expectedTypes)) {
459-
for (let i = 0, len = expectedTypes.length; i < len; i++) {
460-
if (isSameType(expectedTypes[i], type)) {
461-
return i
462-
}
463-
}
459+
return expectedTypes.findIndex(t => isSameType(t, type))
464460
} else if (isFunction(expectedTypes)) {
465461
return isSameType(expectedTypes, type) ? 0 : -1
466462
}

0 commit comments

Comments
 (0)