mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Enable modernize-loop-convert rule in clang-tidy
Summary: changelog: [internal] You can read more about this rule on https://clang.llvm.org/extra/clang-tidy/checks/modernize-loop-convert.html Reviewed By: ShikaSD Differential Revision: D33253673 fbshipit-source-id: db2ec74cc584f2e8eb74ce54c4f50986d8168387
This commit is contained in:
1 parent
bcc4ab35da
commit
26fffe8cbf
5 files changed
+25
-38
No files matched your search
@@ -6,5 +6,6 @@ modernize-avoid-bind,
|
||||
modernize-avoid-c-arrays,
|
||||
modernize-deprecated-headers,
|
||||
modernize-deprecated-ios-base-aliases,
|
||||
modernize-loop-convert,
|
||||
'
|
||||
...
|
||||
@@ -1322,11 +1322,7 @@ void LayoutAnimationKeyFrameManager::
|
||||
continue;
|
||||
}
|
||||
|
||||
for (auto it = inflightAnimation.keyFrames.begin();
|
||||
it != inflightAnimation.keyFrames.end();
|
||||
it++) {
|
||||
auto &animatedKeyFrame = *it;
|
||||
|
||||
for (auto &animatedKeyFrame : inflightAnimation.keyFrames) {
|
||||
if (animatedKeyFrame.invalidated) {
|
||||
continue;
|
||||
}
|
||||
@@ -1430,11 +1426,7 @@ void LayoutAnimationKeyFrameManager::adjustDelayedMutationIndicesForMutation(
|
||||
continue;
|
||||
}
|
||||
|
||||
for (auto it = inflightAnimation.keyFrames.begin();
|
||||
it != inflightAnimation.keyFrames.end();
|
||||
it++) {
|
||||
auto &animatedKeyFrame = *it;
|
||||
|
||||
for (auto &animatedKeyFrame : inflightAnimation.keyFrames) {
|
||||
if (animatedKeyFrame.invalidated) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -895,8 +895,8 @@ static void calculateShadowViewMutationsFlattener(
|
||||
// Construct unvisited nodes map
|
||||
auto unvisitedRecursiveChildPairs =
|
||||
TinyMap<Tag, ShadowViewNodePair *>{};
|
||||
for (size_t i = 0; i < flattenedNodes.size(); i++) {
|
||||
auto &newChild = *flattenedNodes[i];
|
||||
for (auto &flattenedNode : flattenedNodes) {
|
||||
auto &newChild = *flattenedNode;
|
||||
|
||||
auto unvisitedOtherNodesIt =
|
||||
unvisitedOtherNodes.find(newChild.shadowView.tag);
|
||||
@@ -959,14 +959,12 @@ static void calculateShadowViewMutationsFlattener(
|
||||
// If old nodes were not visited, we know that we can delete them
|
||||
// now. They will be removed from the hierarchy by the outermost
|
||||
// loop of this function.
|
||||
for (auto unvisitedOldChildPairIt =
|
||||
unvisitedRecursiveChildPairs.begin();
|
||||
unvisitedOldChildPairIt != unvisitedRecursiveChildPairs.end();
|
||||
unvisitedOldChildPairIt++) {
|
||||
if (unvisitedOldChildPairIt->first == 0) {
|
||||
for (auto &unvisitedRecursiveChildPair :
|
||||
unvisitedRecursiveChildPairs) {
|
||||
if (unvisitedRecursiveChildPair.first == 0) {
|
||||
continue;
|
||||
}
|
||||
auto &oldFlattenedNode = *unvisitedOldChildPairIt->second;
|
||||
auto &oldFlattenedNode = *unvisitedRecursiveChildPair.second;
|
||||
|
||||
// Node unvisited - mark the entire subtree for deletion
|
||||
if (oldFlattenedNode.isConcreteView &&
|
||||
@@ -1026,13 +1024,11 @@ static void calculateShadowViewMutationsFlattener(
|
||||
// Final step: go through creation/deletion candidates and delete/create
|
||||
// subtrees if they were never visited during the execution of the above
|
||||
// loop and recursions.
|
||||
for (auto it = deletionCreationCandidatePairs.begin();
|
||||
it != deletionCreationCandidatePairs.end();
|
||||
it++) {
|
||||
if (it->first == 0) {
|
||||
for (auto &deletionCreationCandidatePair : deletionCreationCandidatePairs) {
|
||||
if (deletionCreationCandidatePair.first == 0) {
|
||||
continue;
|
||||
}
|
||||
auto &treeChildPair = *it->second;
|
||||
auto &treeChildPair = *deletionCreationCandidatePair.second;
|
||||
|
||||
// If node was visited during a flattening/unflattening recursion,
|
||||
// and the node in the other tree is concrete, that means it was
|
||||
@@ -1477,14 +1473,12 @@ static void calculateShadowViewMutationsV2(
|
||||
// subtrees/nodes. We do this here because we need to traverse the entire
|
||||
// list to make sure that a node was not reparented into an unflattened
|
||||
// node that occurs *after* it in the hierarchy, due to zIndex ordering.
|
||||
for (auto it = deletionCandidatePairs.begin();
|
||||
it != deletionCandidatePairs.end();
|
||||
it++) {
|
||||
if (it->first == 0) {
|
||||
for (auto &deletionCandidatePair : deletionCandidatePairs) {
|
||||
if (deletionCandidatePair.first == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
auto const &oldChildPair = *it->second;
|
||||
auto const &oldChildPair = *deletionCandidatePair.second;
|
||||
|
||||
DEBUG_LOGS({
|
||||
LOG(ERROR)
|
||||
@@ -1520,17 +1514,16 @@ static void calculateShadowViewMutationsV2(
|
||||
|
||||
// Final step: generate Create instructions for entirely new
|
||||
// subtrees/nodes that are not the result of flattening or unflattening.
|
||||
for (auto it = newInsertedPairs.begin(); it != newInsertedPairs.end();
|
||||
it++) {
|
||||
for (auto &newInsertedPair : newInsertedPairs) {
|
||||
// Erased elements of a TinyMap will have a Tag/key of 0 - skip those
|
||||
// These *should* be removed by the map; there are currently no KNOWN
|
||||
// cases where TinyMap will do the wrong thing, but there are not yet
|
||||
// any unit tests explicitly for TinyMap, so this is safer for now.
|
||||
if (it->first == 0) {
|
||||
if (newInsertedPair.first == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
auto const &newChildPair = *it->second;
|
||||
auto const &newChildPair = *newInsertedPair.second;
|
||||
|
||||
DEBUG_LOGS({
|
||||
LOG(ERROR)
|
||||
|
||||
@@ -358,9 +358,9 @@ TEST(MountingTest, testReorderingInstructionGeneration) {
|
||||
// The actual nodes that should be created in this transaction have a tag >
|
||||
// 105.
|
||||
EXPECT_TRUE(mutations6.size() == 25);
|
||||
for (int i = 0; i < mutations6.size(); i++) {
|
||||
if (mutations6[i].type == ShadowViewMutation::Create) {
|
||||
EXPECT_TRUE(mutations6[i].newChildShadowView.tag > 105);
|
||||
for (auto &i : mutations6) {
|
||||
if (i.type == ShadowViewMutation::Create) {
|
||||
EXPECT_TRUE(i.newChildShadowView.tag > 105);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+4
-3
@@ -225,9 +225,10 @@ TextMeasurement TextLayoutManager::doMeasure(
|
||||
if (attachmentsCount > 0) {
|
||||
folly::dynamic fragments = serializedAttributedString["fragments"];
|
||||
int attachmentIndex = 0;
|
||||
for (int i = 0; i < fragments.size(); i++) {
|
||||
folly::dynamic fragment = fragments[i];
|
||||
if (fragment["isAttachment"] == true) {
|
||||
for (auto const &fragment : fragments) {
|
||||
auto isAttachment = fragment.find("isAttachment");
|
||||
if (isAttachment != fragment.items().end() &&
|
||||
isAttachment->second.getBool()) {
|
||||
float top = attachmentData[attachmentIndex * 2];
|
||||
float left = attachmentData[attachmentIndex * 2 + 1];
|
||||
float width = (float)fragment["width"].getDouble();
|
||||
|
||||
Reference in new issue
Block a user