removed unnecessary dispatches to main queue

Summary: There is no point in dispatching to main thread if there is nothing to do there.
This place gets called basically any time a repeating js timer fires, which doesn't imply UI changes (although usually that's why people setup timers).
Combined with previous diffs that makes us not generate empty blocks (nil instead), this could be minor perf win in some rare cases.

This also changes semantic of `reactBridgeDidFinishTransaction` call a bit. Previously it was done no matter if UI has changed or not.
I think it should be safe, since seems like callees really care only about views being laid out.

Depends on D2571166. (not strictly speaking)

public

Reviewed By: jspahrsummers, nicklockwood

Differential Revision: D2571188

fb-gh-sync-id: 02d52e4615475072c3c27226e67c431a667ec990
This commit is contained in:
Martin Kralik 2015-10-27 05:07:45 -07:00 коммит произвёл facebook-github-bot-5
Родитель 28f5af0c39
Коммит f916ec26a6
1 изменённых файлов: 20 добавлений и 20 удалений

Просмотреть файл

@ -898,6 +898,7 @@ RCT_EXPORT_METHOD(findSubviewIn:(nonnull NSNumber *)reactTag atPoint:(CGPoint)po
_pendingUIBlocks = [NSMutableArray new];
[_pendingUIBlocksLock unlock];
if (previousPendingUIBlocks.count) {
// Execute the previously queued UI blocks
RCTProfileBeginFlowEvent();
dispatch_async(dispatch_get_main_queue(), ^{
@ -910,12 +911,10 @@ RCT_EXPORT_METHOD(findSubviewIn:(nonnull NSNumber *)reactTag atPoint:(CGPoint)po
/**
* TODO(tadeu): Remove it once and for all
*/
if (previousPendingUIBlocks.count) {
for (id<RCTComponent> node in _bridgeTransactionListeners) {
[node reactBridgeDidFinishTransaction];
}
}
}
@catch (NSException *exception) {
RCTLogError(@"Exception thrown while executing UI block: %@", exception);
}
@ -924,6 +923,7 @@ RCT_EXPORT_METHOD(findSubviewIn:(nonnull NSNumber *)reactTag atPoint:(CGPoint)po
});
});
}
}
RCT_EXPORT_METHOD(measure:(nonnull NSNumber *)reactTag
callback:(RCTResponseSenderBlock)callback)