Reduced work done on main thread by RCTImageLoader

Summary: public

Removed redundant calls to [RCTNetwork canHandleRequest] in release mode when loading images, and improved perf for handler lookups when running in debug mode.

Reviewed By: tadeuzagallo

Differential Revision: D2663307

fb-gh-sync-id: 13285154c1c3773b32dba7894d86d14992e2fd7d
This commit is contained in:
Nick Lockwood
2015-11-17 07:18:55 -08:00
committed by facebook-github-bot-0
parent c043c68e7e
commit 5b796cec34
4 changed files with 126 additions and 102 deletions

View File

@@ -165,8 +165,11 @@ RCT_EXPORT_MODULE()
float previousPriority = 0;
id<RCTURLRequestHandler> previousHandler = nil;
for (id<RCTURLRequestHandler> handler in _handlers) {
float priority = [handler respondsToSelector:@selector(handlerPriority)] ? [handler handlerPriority] : 0;
if (previousHandler && priority < previousPriority) {
return previousHandler;
}
if ([handler canHandleRequest:request]) {
float priority = [handler respondsToSelector:@selector(handlerPriority)] ? [handler handlerPriority] : 0;
if (previousHandler) {
if (priority == previousPriority) {
RCTLogError(@"The RCTURLRequestHandlers %@ and %@ both reported that"
@@ -180,6 +183,7 @@ RCT_EXPORT_MODULE()
}
}
}
return previousHandler;
}
// Normal code path