diff --git a/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm b/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm index b1f1251153..f252344fe6 100644 --- a/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm +++ b/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm @@ -519,7 +519,7 @@ static NSString *RCTRecursiveAccessibilityLabel(UIView *view) { auto const &accessibilityActions = _props->accessibilityActions; - if (accessibilityActions.size() == 0) { + if (accessibilityActions.empty()) { return nil; } diff --git a/React/Fabric/Mounting/RCTComponentViewRegistry.mm b/React/Fabric/Mounting/RCTComponentViewRegistry.mm index 23d08cef83..b0dbe553b0 100644 --- a/React/Fabric/Mounting/RCTComponentViewRegistry.mm +++ b/React/Fabric/Mounting/RCTComponentViewRegistry.mm @@ -189,7 +189,7 @@ const NSInteger RCTComponentViewRegistryRecyclePoolMaxSize = 1024; RCTAssertMainQueue(); auto &recycledViews = _recyclePool[componentHandle]; - if (recycledViews.size() == 0) { + if (recycledViews.empty()) { return [self.componentViewFactory createComponentViewWithComponentHandle:componentHandle]; } diff --git a/React/Fabric/Mounting/RCTMountingManager.mm b/React/Fabric/Mounting/RCTMountingManager.mm index f0c690cd6d..a64b1dd79d 100644 --- a/React/Fabric/Mounting/RCTMountingManager.mm +++ b/React/Fabric/Mounting/RCTMountingManager.mm @@ -274,7 +274,7 @@ static void RNPerformMountInstructions( auto surfaceId = transaction->getSurfaceId(); auto &mutations = transaction->getMutations(); - if (mutations.size() == 0) { + if (mutations.empty()) { return; } diff --git a/React/Fabric/RCTSurfaceTouchHandler.mm b/React/Fabric/RCTSurfaceTouchHandler.mm index e2de89c668..63c3699565 100644 --- a/React/Fabric/RCTSurfaceTouchHandler.mm +++ b/React/Fabric/RCTSurfaceTouchHandler.mm @@ -362,7 +362,7 @@ RCT_NOT_IMPLEMENTED(-(instancetype)initWithTarget : (id)target action : (SEL)act { [super reset]; - if (_activeTouches.size() != 0) { + if (!_activeTouches.empty()) { std::vector activeTouches; activeTouches.reserve(_activeTouches.size()); diff --git a/ReactCommon/fabric/components/image/ImageShadowNode.cpp b/ReactCommon/fabric/components/image/ImageShadowNode.cpp index 030d6d8abb..4a00f2c1bf 100644 --- a/ReactCommon/fabric/components/image/ImageShadowNode.cpp +++ b/ReactCommon/fabric/components/image/ImageShadowNode.cpp @@ -45,7 +45,7 @@ void ImageShadowNode::updateStateIfNeeded() { ImageSource ImageShadowNode::getImageSource() const { auto sources = getConcreteProps().sources; - if (sources.size() == 0) { + if (sources.empty()) { return { /* .type = */ ImageSource::Type::Invalid, }; diff --git a/ReactCommon/fabric/components/view/yoga/YogaLayoutableShadowNode.cpp b/ReactCommon/fabric/components/view/yoga/YogaLayoutableShadowNode.cpp index 04c48fda48..9e15d72e04 100644 --- a/ReactCommon/fabric/components/view/yoga/YogaLayoutableShadowNode.cpp +++ b/ReactCommon/fabric/components/view/yoga/YogaLayoutableShadowNode.cpp @@ -597,7 +597,7 @@ void YogaLayoutableShadowNode::ensureYogaChildrenOwnersConsistency() const { // The owner might be not equal to the `yogaNode_` though. auto &yogaChildren = yogaNode_.getChildren(); - if (yogaChildren.size() > 0) { + if (!yogaChildren.empty()) { auto owner = yogaChildren.at(0)->getOwner(); for (auto const &child : yogaChildren) { assert(child->getOwner() == owner); @@ -617,7 +617,7 @@ void YogaLayoutableShadowNode::ensureYogaChildrenLookFine() const { for (auto const &yogaChild : yogaChildren) { assert(yogaChild->getContext()); assert(yogaChild->getChildren().size() < 16384); - if (yogaChild->getChildren().size() > 0) { + if (!yogaChild->getChildren().empty()) { assert(!yogaChild->hasMeasureFunc()); } } @@ -635,7 +635,7 @@ void YogaLayoutableShadowNode::ensureYogaChildrenAlighment() const { auto &children = getChildren(); if (getTraits().check(ShadowNodeTraits::Trait::LeafYogaNode)) { - assert(yogaChildren.size() == 0); + assert(yogaChildren.empty()); return; } diff --git a/ReactCommon/fabric/core/events/EventQueue.cpp b/ReactCommon/fabric/core/events/EventQueue.cpp index 1d1aa9e6ea..2861d7a14f 100644 --- a/ReactCommon/fabric/core/events/EventQueue.cpp +++ b/ReactCommon/fabric/core/events/EventQueue.cpp @@ -96,7 +96,7 @@ void EventQueue::flushStateUpdates() const { { std::lock_guard lock(queueMutex_); - if (stateUpdateQueue_.size() == 0) { + if (stateUpdateQueue_.empty()) { return; } diff --git a/ReactCommon/fabric/core/layout/LayoutableShadowNode.cpp b/ReactCommon/fabric/core/layout/LayoutableShadowNode.cpp index 4ae44ed720..ec67fbb6e6 100644 --- a/ReactCommon/fabric/core/layout/LayoutableShadowNode.cpp +++ b/ReactCommon/fabric/core/layout/LayoutableShadowNode.cpp @@ -121,7 +121,7 @@ LayoutMetrics LayoutableShadowNode::getRelativeLayoutMetrics( auto ancestors = shadowNode.getFamily().getAncestors(ancestorShadowNode); - if (ancestors.size() == 0) { + if (ancestors.empty()) { return EmptyLayoutMetrics; } diff --git a/ReactCommon/fabric/core/shadownode/ShadowNode.cpp b/ReactCommon/fabric/core/shadownode/ShadowNode.cpp index f54fedcf22..9f3618ddf4 100644 --- a/ReactCommon/fabric/core/shadownode/ShadowNode.cpp +++ b/ReactCommon/fabric/core/shadownode/ShadowNode.cpp @@ -254,7 +254,7 @@ ShadowNode::Unshared ShadowNode::cloneTree( callback) const { auto ancestors = shadowNodeFamily.getAncestors(*this); - if (ancestors.size() == 0) { + if (ancestors.empty()) { return ShadowNode::Unshared{nullptr}; } diff --git a/ReactCommon/fabric/mounting/Differentiator.cpp b/ReactCommon/fabric/mounting/Differentiator.cpp index fd621ecfb4..0e93586411 100644 --- a/ReactCommon/fabric/mounting/Differentiator.cpp +++ b/ReactCommon/fabric/mounting/Differentiator.cpp @@ -65,7 +65,7 @@ class TinyMap final { inline Iterator end() { // `back()` asserts on the vector being non-empty - if (vector_.size() == 0 || numErased_ == vector_.size()) { + if (vector_.empty() || numErased_ == vector_.size()) { return nullptr; } @@ -112,7 +112,7 @@ class TinyMap final { */ inline Iterator begin_() { // `front()` asserts on the vector being non-empty - if (vector_.size() == 0 || vector_.size() == numErased_) { + if (vector_.empty() || vector_.size() == numErased_) { return nullptr; } @@ -125,9 +125,8 @@ class TinyMap final { * vector. */ inline void cleanVector(bool forceClean = false) { - if ((numErased_ < (vector_.size() / 2) && !forceClean) || - vector_.size() == 0 || numErased_ == 0 || - numErased_ == erasedAtFront_) { + if ((numErased_ < (vector_.size() / 2) && !forceClean) || vector_.empty() || + numErased_ == 0 || numErased_ == erasedAtFront_) { return; } @@ -259,7 +258,7 @@ static void calculateShadowViewMutations( ShadowView const &parentShadowView, ShadowViewNodePair::List &&oldChildPairs, ShadowViewNodePair::List &&newChildPairs) { - if (oldChildPairs.size() == 0 && newChildPairs.size() == 0) { + if (oldChildPairs.empty() && newChildPairs.empty()) { return; } diff --git a/ReactCommon/fabric/mounting/ShadowTree.cpp b/ReactCommon/fabric/mounting/ShadowTree.cpp index 654d26fed0..a6e4c2c58e 100644 --- a/ReactCommon/fabric/mounting/ShadowTree.cpp +++ b/ReactCommon/fabric/mounting/ShadowTree.cpp @@ -41,7 +41,7 @@ static ShadowNode::Unshared progressState(ShadowNode const &shadowNode) { } auto newChildren = ShadowNode::ListOfShared{}; - if (shadowNode.getChildren().size() > 0) { + if (!shadowNode.getChildren().empty()) { auto index = size_t{0}; for (auto const &childNode : shadowNode.getChildren()) { auto newChildNode = progressState(*childNode); @@ -170,7 +170,7 @@ static void updateMountedFlag( return; } - if (oldChildren.size() == 0 && newChildren.size() == 0) { + if (oldChildren.empty() && newChildren.empty()) { // Both lists are empty, nothing to do. return; } diff --git a/ReactCommon/fabric/mounting/ShadowTreeRegistry.cpp b/ReactCommon/fabric/mounting/ShadowTreeRegistry.cpp index f2792af365..1564bbee14 100644 --- a/ReactCommon/fabric/mounting/ShadowTreeRegistry.cpp +++ b/ReactCommon/fabric/mounting/ShadowTreeRegistry.cpp @@ -12,8 +12,7 @@ namespace react { ShadowTreeRegistry::~ShadowTreeRegistry() { assert( - registry_.size() == 0 && - "Deallocation of non-empty `ShadowTreeRegistry`."); + registry_.empty() && "Deallocation of non-empty `ShadowTreeRegistry`."); } void ShadowTreeRegistry::add(std::unique_ptr &&shadowTree) const { diff --git a/ReactCommon/fabric/scheduler/Scheduler.cpp b/ReactCommon/fabric/scheduler/Scheduler.cpp index cc15c23efc..cc67b56709 100644 --- a/ReactCommon/fabric/scheduler/Scheduler.cpp +++ b/ReactCommon/fabric/scheduler/Scheduler.cpp @@ -118,10 +118,10 @@ Scheduler::~Scheduler() { }); assert( - surfaceIds.size() == 0 && + surfaceIds.empty() && "Scheduler was destroyed with outstanding Surfaces."); - if (surfaceIds.size() == 0) { + if (surfaceIds.empty()) { return; } @@ -177,7 +177,7 @@ void Scheduler::renderTemplateToSurface( const std::string &uiTemplate) { SystraceSection s("Scheduler::renderTemplateToSurface"); try { - if (uiTemplate.size() == 0) { + if (uiTemplate.empty()) { return; } NativeModuleRegistry nMR; diff --git a/ReactCommon/fabric/uimanager/UIManager.cpp b/ReactCommon/fabric/uimanager/UIManager.cpp index a4bc38f25d..3de1d006fd 100644 --- a/ReactCommon/fabric/uimanager/UIManager.cpp +++ b/ReactCommon/fabric/uimanager/UIManager.cpp @@ -153,7 +153,7 @@ ShadowNode::Shared UIManager::getNewestCloneOfShadowNode( auto ancestors = shadowNode.getFamily().getAncestors(*ancestorShadowNode); - if (ancestors.size() == 0) { + if (ancestors.empty()) { return nullptr; }