refactor(runtime-core): use Array.from instead of loop over iterable (#250)

This commit is contained in:
fisker Cheung 2019-10-13 07:34:22 +08:00 committed by Evan You
parent 96681942c1
commit cdc143d348

View File

@ -16,13 +16,10 @@ export function renderList(
} }
} else if (isObject(source)) { } else if (isObject(source)) {
if (source[Symbol.iterator as any]) { if (source[Symbol.iterator as any]) {
ret = [] ret = Array.from(
const iterator: Iterator<any> = source[Symbol.iterator as any]() source as Iterable<any>,
let result = iterator.next() renderItem
while (!result.done) { )
ret.push(renderItem(result.value, ret.length))
result = iterator.next()
}
} else { } else {
const keys = Object.keys(source) const keys = Object.keys(source)
ret = new Array(keys.length) ret = new Array(keys.length)