Avoid wrapping every UIManager block in another block
Reviewed By: majak Differential Revision: D3555003 fbshipit-source-id: e7fd5373d002e98bdeb566deaca4345de56c3414
This commit is contained in:
parent
8d24cb4677
commit
b9f391d616
|
@ -206,7 +206,7 @@ static UIViewAnimationOptions UIViewAnimationOptionsFromRCTAnimationType(RCTAnim
|
|||
{
|
||||
// Root views are only mutated on the shadow queue
|
||||
NSMutableSet<NSNumber *> *_rootViewTags;
|
||||
NSMutableArray<dispatch_block_t> *_pendingUIBlocks;
|
||||
NSMutableArray<RCTViewManagerUIBlock> *_pendingUIBlocks;
|
||||
|
||||
// Animation
|
||||
RCTLayoutAnimation *_layoutAnimation; // Main thread only
|
||||
|
@ -512,15 +512,7 @@ dispatch_queue_t RCTGetUIManagerQueue(void)
|
|||
return;
|
||||
}
|
||||
|
||||
__weak RCTUIManager *weakSelf = self;
|
||||
dispatch_block_t outerBlock = ^{
|
||||
RCTUIManager *strongSelf = weakSelf;
|
||||
if (strongSelf && strongSelf->_viewRegistry) {
|
||||
block(strongSelf, strongSelf->_viewRegistry);
|
||||
}
|
||||
};
|
||||
|
||||
[_pendingUIBlocks addObject:outerBlock];
|
||||
[_pendingUIBlocks addObject:block];
|
||||
}
|
||||
|
||||
- (RCTViewManagerUIBlock)uiBlockWithLayoutUpdateForRootView:(RCTRootShadowView *)rootShadowView
|
||||
|
@ -1152,7 +1144,7 @@ RCT_EXPORT_METHOD(dispatchViewManagerCommand:(nonnull NSNumber *)reactTag
|
|||
// First copy the previous blocks into a temporary variable, then reset the
|
||||
// pending blocks to a new array. This guards against mutation while
|
||||
// processing the pending blocks in another thread.
|
||||
NSArray<dispatch_block_t> *previousPendingUIBlocks = _pendingUIBlocks;
|
||||
NSArray<RCTViewManagerUIBlock> *previousPendingUIBlocks = _pendingUIBlocks;
|
||||
_pendingUIBlocks = [NSMutableArray new];
|
||||
|
||||
if (previousPendingUIBlocks.count) {
|
||||
|
@ -1162,8 +1154,8 @@ RCT_EXPORT_METHOD(dispatchViewManagerCommand:(nonnull NSNumber *)reactTag
|
|||
RCTProfileEndFlowEvent();
|
||||
RCT_PROFILE_BEGIN_EVENT(RCTProfileTagAlways, @"-[UIManager flushUIBlocks]", nil);
|
||||
@try {
|
||||
for (dispatch_block_t block in previousPendingUIBlocks) {
|
||||
block();
|
||||
for (RCTViewManagerUIBlock block in previousPendingUIBlocks) {
|
||||
block(self, self->_viewRegistry);
|
||||
}
|
||||
}
|
||||
@catch (NSException *exception) {
|
||||
|
|
Loading…
Reference in New Issue