List diff

Tags
algorithmwebapp
Created
May 17, 2021 1:32 PM

以最小成本找到 List 元素的更改

// 可以使用 Map + WeakRef + FinalizationRegistry 实现 key+value 弱引用

https://reactjs.org/docs/reconciliation.html

https://indepth.dev/posts/1008/inside-fiber-in-depth-overview-of-the-new-reconciliation-algorithm-in-react#general-algorithm

Reconciliation algorithm // 从列表中找到新增的和删除的项

https://github.com/lit/lit/blob/lit-html-1.x/src/directives/repeat.ts#L71

用头尾指针分别在 old new keys 中向中间移动,多余的项目就判断为新的或者过时的 // 类似 vue 双端比较?

// 新旧都有余项需要遍历比较

SuperMade with Super