What is the advantage of maintaining four indexes in the diff algorithm of virtual dom?

The diff algorithm of almost all virtual dom on the

network maintains four index variables to make dom changes. Excuse me, what is the advantage of this kind of algorithm, and why do all choose this kind of algorithm?

what are the disadvantages if I use a simple loop operation algorithm (such as below)?

iterate through the nodes of the newVdom one by one to find its location in the oldVdom, move the corresponding DOM element if it is found, and create a new node to insert if it does not show that it is a new node. If there are any unprocessed nodes in the oldVdom after traversal, these nodes have been deleted in the newVdom, and you can delete them.

Mar.21,2021
Menu