我有一个大约 50k 个项目的大阵列,其中每个项目都符合可识别的要求。
我不会以任何方式改变数组,例如重新排列或任何其他方式。
如果我将其直接传递给 ForEach,列表滚动性能会比传递索引时明显更加流畅。
我意识到文档中提到了与每个细胞的结构特性有关的事情,但我无法理解为什么会出现这种情况。
ForEach(myArray, id: \.id) { item in
MyRowView(item: item)
}
// Extremely choppy scroll
ForEach(myArray.indices, id: \.self) { index in
MyRowView(item: myArray[index])
}