Skip to content

Commit 15f0895

Browse files
cipolleschifacebook-github-bot
authored andcommitted
Optimize RCTUIManager to avoid too many calls to viewForReactTag
Summary: This change fixes a couple of issues within the RCTUIManager: * it calls the right method in the `super` branches (although they should neve be executed) * it invert the call order between the `_registry` and the `uiManager` to avoid extra calls into the `viewForReactTag`. ## Changelog: [Internal] - Use the right method in super and invert the order of where we search for views. ## Facebook: See S397861 and T180527210 for more information. Reviewed By: javache Differential Revision: D54246220 fbshipit-source-id: 1c7503ad3e80cf50ecc016a984ca180a19b73cc0
1 parent f5d5d9d commit 15f0895

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

packages/react-native/React/Modules/RCTUIManager.m

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1674,28 +1674,28 @@ - (instancetype)initWithUIManager:(RCTUIManager *)uiManager andRegistry:(NSDicti
16741674
{
16751675
self = [super init];
16761676
if (self) {
1677-
self->_uiManager = uiManager;
1678-
self->_registry = registry;
1677+
_uiManager = uiManager;
1678+
_registry = registry;
16791679
}
16801680
return self;
16811681
}
16821682

16831683
- (id)objectForKey:(id)key
16841684
{
16851685
if (![key isKindOfClass:[NSNumber class]]) {
1686-
return [super objectForKeyedSubscript:key];
1686+
return [super objectForKey:key];
16871687
}
16881688

16891689
NSNumber *index = (NSNumber *)key;
1690-
UIView *view = [_uiManager viewForReactTag:index];
1690+
UIView *view = _registry[index];
16911691
if (view) {
16921692
return [RCTUIManager paperViewOrCurrentView:view];
16931693
}
1694-
view = _registry[index];
1694+
view = [_uiManager viewForReactTag:index];
16951695
if (view) {
16961696
return [RCTUIManager paperViewOrCurrentView:view];
16971697
}
1698-
return [super objectForKeyedSubscript:key];
1698+
return [super objectForKey:key];
16991699
}
17001700

17011701
- (void)removeObjectForKey:(id)key

0 commit comments

Comments
 (0)