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
This commit is contained in:
Riccardo Cipolleschi
2024-05-01 18:07:02 +01:00
committed by Riccardo Cipolleschi
parent 60962b4406
commit df6bec5427
@@ -1674,8 +1674,8 @@ static UIView *_jsResponder;
{
self = [super init];
if (self) {
self->_uiManager = uiManager;
self->_registry = registry;
_uiManager = uiManager;
_registry = registry;
}
return self;
}
@@ -1693,19 +1693,19 @@ static UIView *_jsResponder;
- (id)objectForKey:(id)key
{
if (![key isKindOfClass:[NSNumber class]]) {
return [super objectForKeyedSubscript:key];
return [super objectForKey:key];
}
NSNumber *index = (NSNumber *)key;
UIView *view = [_uiManager viewForReactTag:index];
UIView *view = _registry[index];
if (view) {
return [RCTUIManager paperViewOrCurrentView:view];
}
view = _registry[index];
view = [_uiManager viewForReactTag:index];
if (view) {
return [RCTUIManager paperViewOrCurrentView:view];
}
return [super objectForKeyedSubscript:key];
return [super objectForKey:key];
}
- (void)removeObjectForKey:(id)key