Replace folly::Optional with std::optional (#35436)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/35436

Using std::optional as react-native has been using C++17 for quite some time

changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D41415031

fbshipit-source-id: d786647f64b4f90cf75409109830ae0885460c17
This commit is contained in:
Christoph Purrer
2022-11-28 02:08:12 -08:00
committed by Facebook GitHub Bot
parent 6e9d3bf7b1
commit 022e22cbd4
18 changed files with 51 additions and 52 deletions
+5 -6
View File
@@ -92,8 +92,7 @@ std::vector<std::string> ModuleRegistry::moduleNames() {
return names;
}
folly::Optional<ModuleConfig> ModuleRegistry::getConfig(
const std::string &name) {
std::optional<ModuleConfig> ModuleRegistry::getConfig(const std::string &name) {
SystraceSection s("ModuleRegistry::getConfig", "module", name);
// Initialize modulesByName_
@@ -107,14 +106,14 @@ folly::Optional<ModuleConfig> ModuleRegistry::getConfig(
if (unknownModules_.find(name) != unknownModules_.end()) {
BridgeNativeModulePerfLogger::moduleJSRequireBeginningFail(name.c_str());
BridgeNativeModulePerfLogger::moduleJSRequireEndingStart(name.c_str());
return folly::none;
return std::nullopt;
}
if (!moduleNotFoundCallback_) {
unknownModules_.insert(name);
BridgeNativeModulePerfLogger::moduleJSRequireBeginningFail(name.c_str());
BridgeNativeModulePerfLogger::moduleJSRequireEndingStart(name.c_str());
return folly::none;
return std::nullopt;
}
BridgeNativeModulePerfLogger::moduleJSRequireBeginningEnd(name.c_str());
@@ -128,7 +127,7 @@ folly::Optional<ModuleConfig> ModuleRegistry::getConfig(
if (!wasModuleRegisteredWithRegistry) {
BridgeNativeModulePerfLogger::moduleJSRequireEndingStart(name.c_str());
unknownModules_.insert(name);
return folly::none;
return std::nullopt;
}
} else {
BridgeNativeModulePerfLogger::moduleJSRequireBeginningEnd(name.c_str());
@@ -187,7 +186,7 @@ folly::Optional<ModuleConfig> ModuleRegistry::getConfig(
if (config.size() == 2 && config[1].empty()) {
// no constants or methods
return folly::none;
return std::nullopt;
} else {
return ModuleConfig{index, std::move(config)};
}