perf(v-for): use faster array population in renderList
This commit is contained in:
parent
32499b16e7
commit
b20b922d99
@ -5,14 +5,16 @@ export function renderList(
|
||||
source: any,
|
||||
renderItem: (value: any, key: string | number, index?: number) => VNodeChild
|
||||
): VNodeChild[] {
|
||||
let ret: VNodeChild[] = []
|
||||
let ret: VNodeChild[]
|
||||
if (isArray(source) || isString(source)) {
|
||||
ret = new Array(source.length)
|
||||
for (let i = 0, l = source.length; i < l; i++) {
|
||||
ret.push(renderItem(source[i], i))
|
||||
ret[i] = renderItem(source[i], i)
|
||||
}
|
||||
} else if (typeof source === 'number') {
|
||||
ret = new Array(source)
|
||||
for (let i = 0; i < source; i++) {
|
||||
ret.push(renderItem(i + 1, i))
|
||||
ret[i] = renderItem(i + 1, i)
|
||||
}
|
||||
} else if (isObject(source)) {
|
||||
if (source[Symbol.iterator as any]) {
|
||||
@ -26,5 +28,5 @@ export function renderList(
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret
|
||||
return ret!
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user