react-native/ReactCommon/fabric/uimanager/ComponentDescriptorRegistry.cpp
Valentin Shergin 5463fc260b Fabric: ComponentDescriptorRegistry::operator[] marked as const
Summary:
Quite trivial.
Note that std::unordered_map's `operator[]` is not `const`, so we have to use `at` instead.

Reviewed By: mdvacca

Differential Revision: D7467799

fbshipit-source-id: df38b21dccee4b347f7c070600af0d52f38d6570
2018-04-10 12:59:51 -07:00

27 lines
968 B
C++

// Copyright 2004-present Facebook. All Rights Reserved.
#include "ComponentDescriptorRegistry.h"
namespace facebook {
namespace react {
void ComponentDescriptorRegistry::registerComponentDescriptor(SharedComponentDescriptor componentDescriptor) {
ComponentHandle componentHandle = componentDescriptor->getComponentHandle();
_registryByHandle[componentHandle] = componentDescriptor;
ComponentName componentName = componentDescriptor->getComponentName();
_registryByName[componentName] = componentDescriptor;
}
const SharedComponentDescriptor ComponentDescriptorRegistry::operator[](const SharedShadowNode &shadowNode) const {
ComponentHandle componentHandle = shadowNode->getComponentHandle();
return _registryByHandle.at(componentHandle);
}
const SharedComponentDescriptor ComponentDescriptorRegistry::operator[](const ComponentName &componentName) const {
return _registryByName.at(componentName);
}
} // namespace react
} // namespace facebook