Skip to content

Commit

Permalink
Force Diffing algorithm to insert views Bottom Up (from children to r…
Browse files Browse the repository at this point in the history
…oot)

Summary:
This diff changes the way views are inserted by the diffing algorithm.
Previously the diffing algorithm inserted views top-down, now it insert views bottom-up (same order as previous version of RN).

Let say we need to create the following tree:
```

A --> B --> C
      |
      | --> D

```

Before, the diffing algorithm created the following list of instructions:
```
insert(A, B, 0)
insert(B, C, 0)
insert(B, D, 1)
```

After this diff, the insert instructions are going to be:

```
insert(B, C, 0)
insert(B, D, 1)
insert(A, B, 0)
```

Reviewed By: shergin

Differential Revision: D14817454

fbshipit-source-id: 7aac1a1e1784c53bca2747aee80a5bc8ee788e7a
  • Loading branch information
mdvacca authored and facebook-github-bot committed Apr 10, 2019
1 parent 9202d4f commit 5850bd0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ReactCommon/fabric/mounting/Differentiator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,10 @@ static void calculateShadowViewMutations(
mutations.end(), deleteMutations.begin(), deleteMutations.end());
mutations.insert(
mutations.end(), createMutations.begin(), createMutations.end());
mutations.insert(
mutations.end(), insertMutations.begin(), insertMutations.end());
mutations.insert(
mutations.end(), downwardMutations.begin(), downwardMutations.end());
mutations.insert(
mutations.end(), insertMutations.begin(), insertMutations.end());
}

ShadowViewMutationList calculateShadowViewMutations(
Expand Down

0 comments on commit 5850bd0

Please sign in to comment.