Skip to content

Commit 60591d7

Browse files
committed
perf(runtime-core): use for of to replace for loop
1 parent a177092 commit 60591d7

File tree

1 file changed

+5
-19
lines changed

1 file changed

+5
-19
lines changed

packages/runtime-core/src/helpers/renderList.ts

+5-19
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
11
import type { VNode, VNodeChild } from '../vnode'
2-
import {
3-
isReactive,
4-
isShallow,
5-
shallowReadArray,
6-
toReactive,
7-
} from '@vue/reactivity'
82
import { isArray, isObject, isString } from '@vue/shared'
93
import { warn } from '../warning'
104

@@ -67,20 +61,12 @@ export function renderList(
6761
const sourceIsArray = isArray(source)
6862

6963
if (sourceIsArray || isString(source)) {
70-
const sourceIsReactiveArray = sourceIsArray && isReactive(source)
71-
let needsWrap = false
72-
if (sourceIsReactiveArray) {
73-
needsWrap = !isShallow(source)
74-
source = shallowReadArray(source)
75-
}
7664
ret = new Array(source.length)
77-
for (let i = 0, l = source.length; i < l; i++) {
78-
ret[i] = renderItem(
79-
needsWrap ? toReactive(source[i]) : source[i],
80-
i,
81-
undefined,
82-
cached && cached[i],
83-
)
65+
let i = 0
66+
67+
for (let sourceItem of source) {
68+
ret[i] = renderItem(sourceItem, i, undefined, cached && cached[i])
69+
i++
8470
}
8571
} else if (typeof source === 'number') {
8672
if (__DEV__ && !Number.isInteger(source)) {

0 commit comments

Comments
 (0)