From 28d26c2e5628b02a7b76d7e4b2ca438d1fcd7487 Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Wed, 28 Aug 2019 21:08:27 -0700 Subject: [PATCH] Fabric: Small optimization in RCTMountingManager Summary: `pullTransaction` can return an empty transaction. That's fine to interate over the empty collection and do nothing, but it's inneficient because we also call delegate methods around the loop (that can be expensive). Reviewed By: sammy-SC Differential Revision: D17053430 fbshipit-source-id: c78959d47ea22cd9bb99419f6a80de3ac8e89fd3 --- React/Fabric/Mounting/RCTMountingManager.mm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/React/Fabric/Mounting/RCTMountingManager.mm b/React/Fabric/Mounting/RCTMountingManager.mm index 48eeeff15ee..54b3d70757d 100644 --- a/React/Fabric/Mounting/RCTMountingManager.mm +++ b/React/Fabric/Mounting/RCTMountingManager.mm @@ -251,10 +251,15 @@ static void RNPerformMountInstructions(ShadowViewMutationList const &mutations, } auto surfaceId = transaction->getSurfaceId(); + auto &mutations = transaction->getMutations(); + + if (mutations.size() == 0) { + return; + } RCTAssertMainQueue(); [self.delegate mountingManager:self willMountComponentsWithRootTag:surfaceId]; - RNPerformMountInstructions(transaction->getMutations(), self.componentViewRegistry); + RNPerformMountInstructions(mutations, self.componentViewRegistry); [self.delegate mountingManager:self didMountComponentsWithRootTag:surfaceId]; }