-
Notifications
You must be signed in to change notification settings - Fork 24.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move comparision functions to separate file
Summary: changelog: [internal] Just moving two functions to separate file. Reviewed By: RSNara Differential Revision: D30765732 fbshipit-source-id: e85e749c2910f6f38f07e56b23a21fb9f1cbc9b5
- Loading branch information
1 parent
661b11e
commit 4fe72bd
Showing
4 changed files
with
76 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <react/renderer/mounting/ShadowViewMutation.h> | ||
|
||
namespace facebook { | ||
namespace react { | ||
|
||
static inline bool shouldFirstComeBeforeSecondRemovesOnly( | ||
ShadowViewMutation const &lhs, | ||
ShadowViewMutation const &rhs) noexcept { | ||
// Make sure that removes on the same level are sorted - highest indices must | ||
// come first. | ||
return (lhs.type == ShadowViewMutation::Type::Remove && | ||
lhs.type == rhs.type) && | ||
(lhs.parentShadowView.tag == rhs.parentShadowView.tag) && | ||
(lhs.index > rhs.index); | ||
} | ||
|
||
static inline bool shouldFirstComeBeforeSecondMutation( | ||
ShadowViewMutation const &lhs, | ||
ShadowViewMutation const &rhs) noexcept { | ||
if (lhs.type != rhs.type) { | ||
// Deletes always come last | ||
if (lhs.type == ShadowViewMutation::Type::Delete) { | ||
return false; | ||
} | ||
if (rhs.type == ShadowViewMutation::Type::Delete) { | ||
return true; | ||
} | ||
|
||
// Remove comes before insert | ||
if (lhs.type == ShadowViewMutation::Type::Remove && | ||
rhs.type == ShadowViewMutation::Type::Insert) { | ||
return true; | ||
} | ||
if (rhs.type == ShadowViewMutation::Type::Remove && | ||
lhs.type == ShadowViewMutation::Type::Insert) { | ||
return false; | ||
} | ||
|
||
// Create comes before insert | ||
if (lhs.type == ShadowViewMutation::Type::Create && | ||
rhs.type == ShadowViewMutation::Type::Insert) { | ||
return true; | ||
} | ||
if (rhs.type == ShadowViewMutation::Type::Create && | ||
lhs.type == ShadowViewMutation::Type::Insert) { | ||
return false; | ||
} | ||
} else { | ||
// Make sure that removes on the same level are sorted - highest indices | ||
// must come first. | ||
if (lhs.type == ShadowViewMutation::Type::Remove && | ||
lhs.parentShadowView.tag == rhs.parentShadowView.tag) { | ||
if (lhs.index > rhs.index) { | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
} | ||
} | ||
|
||
return false; | ||
} | ||
|
||
} // namespace react | ||
} // namespace facebook |