perf(runtime-core): optimize the performance of getTypeIndex (#3206)
This commit is contained in:
parent
c8df6185fe
commit
2e50acfbb8
@ -456,11 +456,7 @@ function getTypeIndex(
|
|||||||
expectedTypes: PropType<any> | void | null | true
|
expectedTypes: PropType<any> | void | null | true
|
||||||
): number {
|
): number {
|
||||||
if (isArray(expectedTypes)) {
|
if (isArray(expectedTypes)) {
|
||||||
for (let i = 0, len = expectedTypes.length; i < len; i++) {
|
return expectedTypes.findIndex(t => isSameType(t, type))
|
||||||
if (isSameType(expectedTypes[i], type)) {
|
|
||||||
return i
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (isFunction(expectedTypes)) {
|
} else if (isFunction(expectedTypes)) {
|
||||||
return isSameType(expectedTypes, type) ? 0 : -1
|
return isSameType(expectedTypes, type) ? 0 : -1
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user