Avoid dispatch_async on RCTProfile when not profiling

Summary: public

Fixes #3953

Bail out soon when the profiler is not running + move string formating into the macro so that it happens in a background queue.

Reviewed By: jspahrsummers

Differential Revision: D2696167

fb-gh-sync-id: a1b91ee4459078ab9a4c0be62bd23362ec05e208
This commit is contained in:
Tadeu Zagallo
2015-11-26 03:15:04 -08:00
committed by facebook-github-bot-0
parent 9365414559
commit ea96a7edb8
2 changed files with 22 additions and 17 deletions

View File

@@ -871,12 +871,11 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithBundleURL:(__unused NSURL *)bundleUR
for (RCTModuleData *moduleData in _frameUpdateObservers) {
id<RCTFrameUpdateObserver> observer = (id<RCTFrameUpdateObserver>)moduleData.instance;
if (!observer.paused) {
RCT_IF_DEV(NSString *name = [NSString stringWithFormat:@"[%@ didUpdateFrame:%f]", observer, displayLink.timestamp];)
RCTProfileBeginFlowEvent();
[self dispatchBlock:^{
RCTProfileEndFlowEvent();
RCT_PROFILE_BEGIN_EVENT(0, name, nil);
RCT_PROFILE_BEGIN_EVENT(0, [NSString stringWithFormat:@"[%@ didUpdateFrame:%f]", observer, displayLink.timestamp], nil);
[observer didUpdateFrame:frameUpdate];
RCT_PROFILE_END_EVENT(0, @"objc_call,fps", nil);
} queue:moduleData.methodQueue];