'React diff why not mapRemainingChildren at once directly?

I spent time reading stuff about React diff algorithm recently, and I get to know there are two steps of array-like children diff:

  1. loop from both current first fiber and react first element, compare type until conflicts
  2. mapRemainingChildren and keep looping the remaing react element , try find usable old fiber.

So, here is my question, why not mapping all old fiber at once ? Like why not only use step2 ?

I believe both steps above should share a same time complexity like O(N), to keep React diff average O(N). And step2 could cover cases in step1. So, I think step1 is quite redundant.

Is there any more consideration about this design?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source