Fabric: Using better::map in Prop parsing infra
Summary: It can save us a couple of ms, hopefully. Reviewed By: mdvacca Differential Revision: D14249196 fbshipit-source-id: b5911bcd8b49be66de7b9d2da660df38ef7cc8cd
This commit is contained in:
Родитель
2409fbaeba
Коммит
e93522b14b
|
@ -7,6 +7,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <better/map.h>
|
||||
#include <folly/dynamic.h>
|
||||
#include <react/graphics/conversions.h>
|
||||
#include <react/imagemanager/primitives.h>
|
||||
|
@ -20,8 +21,8 @@ inline void fromRawValue(const RawValue &value, ImageSource &result) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (value.hasType<std::unordered_map<std::string, RawValue>>()) {
|
||||
auto items = (std::unordered_map<std::string, RawValue>)value;
|
||||
if (value.hasType<better::map<std::string, RawValue>>()) {
|
||||
auto items = (better::map<std::string, RawValue>)value;
|
||||
result = {};
|
||||
|
||||
result.type = ImageSource::Type::Remote;
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <better/map.h>
|
||||
#include <folly/Conv.h>
|
||||
#include <folly/dynamic.h>
|
||||
#include <react/components/view/primitives.h>
|
||||
|
@ -361,8 +362,7 @@ inline void fromRawValue(const RawValue &value, Transform &result) {
|
|||
auto configurations = (std::vector<RawValue>)value;
|
||||
|
||||
for (const auto &configuration : configurations) {
|
||||
auto configurationPair =
|
||||
(std::unordered_map<std::string, RawValue>)configuration;
|
||||
auto configurationPair = (better::map<std::string, RawValue>)configuration;
|
||||
auto pair = configurationPair.begin();
|
||||
auto operation = pair->first;
|
||||
auto ¶meters = pair->second;
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <better/map.h>
|
||||
#include <folly/dynamic.h>
|
||||
#include <jsi/JSIDynamic.h>
|
||||
#include <jsi/jsi.h>
|
||||
|
@ -46,7 +47,7 @@ class RawProps {
|
|||
#ifdef ANDROID
|
||||
dynamic_(dynamic),
|
||||
#endif
|
||||
map_((std::unordered_map<std::string, RawValue>)RawValue(dynamic)) {
|
||||
map_((better::map<std::string, RawValue>)RawValue(dynamic)) {
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -90,7 +91,7 @@ class RawProps {
|
|||
const folly::dynamic dynamic_;
|
||||
#endif
|
||||
|
||||
const std::unordered_map<std::string, RawValue> map_;
|
||||
const better::map<std::string, RawValue> map_;
|
||||
};
|
||||
|
||||
} // namespace react
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <better/map.h>
|
||||
#include <folly/dynamic.h>
|
||||
#include <jsi/JSIDynamic.h>
|
||||
#include <jsi/jsi.h>
|
||||
|
@ -180,7 +181,7 @@ class RawValue {
|
|||
template <typename T>
|
||||
static bool checkValueType(
|
||||
const folly::dynamic &dynamic,
|
||||
std::unordered_map<std::string, T> *type) noexcept {
|
||||
better::map<std::string, T> *type) noexcept {
|
||||
if (!dynamic.isObject()) {
|
||||
return false;
|
||||
}
|
||||
|
@ -249,11 +250,11 @@ class RawValue {
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
static std::unordered_map<std::string, T> castValue(
|
||||
static better::map<std::string, T> castValue(
|
||||
const folly::dynamic &dynamic,
|
||||
std::unordered_map<std::string, T> *type) noexcept {
|
||||
better::map<std::string, T> *type) noexcept {
|
||||
assert(dynamic.isObject());
|
||||
auto result = std::unordered_map<std::string, T>{};
|
||||
auto result = better::map<std::string, T>{};
|
||||
for (const auto &item : dynamic.items()) {
|
||||
assert(item.first.isString());
|
||||
result[item.first.getString()] = castValue(item.second, (T *)nullptr);
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <better/map.h>
|
||||
#include <folly/dynamic.h>
|
||||
#include <react/core/RawProps.h>
|
||||
#include <react/graphics/Color.h>
|
||||
|
@ -70,8 +71,8 @@ inline std::string toString(const SharedColor &value) {
|
|||
#pragma mark - Geometry
|
||||
|
||||
inline void fromRawValue(const RawValue &value, Point &result) {
|
||||
if (value.hasType<std::unordered_map<std::string, Float>>()) {
|
||||
auto map = (std::unordered_map<std::string, Float>)value;
|
||||
if (value.hasType<better::map<std::string, Float>>()) {
|
||||
auto map = (better::map<std::string, Float>)value;
|
||||
result = {map.at("x"), map.at("y")};
|
||||
return;
|
||||
}
|
||||
|
@ -87,8 +88,8 @@ inline void fromRawValue(const RawValue &value, Point &result) {
|
|||
}
|
||||
|
||||
inline void fromRawValue(const RawValue &value, Size &result) {
|
||||
if (value.hasType<std::unordered_map<std::string, Float>>()) {
|
||||
auto map = (std::unordered_map<std::string, Float>)value;
|
||||
if (value.hasType<better::map<std::string, Float>>()) {
|
||||
auto map = (better::map<std::string, Float>)value;
|
||||
result = {map.at("width"), map.at("height")};
|
||||
return;
|
||||
}
|
||||
|
@ -109,8 +110,8 @@ inline void fromRawValue(const RawValue &value, EdgeInsets &result) {
|
|||
result = {number, number, number, number};
|
||||
}
|
||||
|
||||
if (value.hasType<std::unordered_map<std::string, Float>>()) {
|
||||
auto map = (std::unordered_map<std::string, Float>)value;
|
||||
if (value.hasType<better::map<std::string, Float>>()) {
|
||||
auto map = (better::map<std::string, Float>)value;
|
||||
result = {map.at("top"), map.at("left"), map.at("bottom"), map.at("right")};
|
||||
return;
|
||||
}
|
||||
|
@ -131,8 +132,8 @@ inline void fromRawValue(const RawValue &value, CornerInsets &result) {
|
|||
result = {number, number, number, number};
|
||||
}
|
||||
|
||||
if (value.hasType<std::unordered_map<std::string, Float>>()) {
|
||||
auto map = (std::unordered_map<std::string, Float>)value;
|
||||
if (value.hasType<better::map<std::string, Float>>()) {
|
||||
auto map = (better::map<std::string, Float>)value;
|
||||
result = {map.at("topLeft"),
|
||||
map.at("topRight"),
|
||||
map.at("bottomLeft"),
|
||||
|
|
Загрузка…
Ссылка в новой задаче