Fix Optimized Differ (was generating extraneous Create mutations)

Summary:
When we call `.erase` on the TinyMap, it sets the key of the element to 0. When we call `.begin()` later, TinyMap will sometimes, but not always, clean up the underlying Vector. This means that *most* of the time, underlying erased elements will be removed from the Vector; but sometimes erased elements will still be there when iterating over it.

This was causing us to generate extra "Create" mutations.

To fix this, for now we just check for zeroed-out elements when iterating over the vector.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D21389371

fbshipit-source-id: 1e641050987d40a3f3e31499dcb373cfb28ae6f8
This commit is contained in:
Joshua Gross 2020-05-04 16:01:24 -07:00 коммит произвёл Facebook GitHub Bot
Родитель ced959bb3d
Коммит d815be1c99
1 изменённых файлов: 6 добавлений и 0 удалений

Просмотреть файл

@ -655,6 +655,12 @@ static void calculateShadowViewMutationsOptimizedMoves(
// Final step: generate Create instructions for new nodes
for (auto it = newInsertedPairs.begin(); it != newInsertedPairs.end();
it++) {
// Erased elements of a TinyMap will have a Tag/key of 0 - skip those
// These *should* be removed by the map, but are not always.
if (it->first == 0) {
continue;
}
auto const &newChildPair = *it->second;
createMutations.push_back(
ShadowViewMutation::CreateMutation(newChildPair.shadowView));