Files
react-native/ReactCommon/fabric/core/tests/TestComponent.h
T
Valentin Shergin 874f656435 Fabric: Rethinking of prop parsing infra
Summary:
This diff reimplements the prop parsing infrastructure in a part where it interacts with RawProps value.

Local synthetic tests show that the new way is 3x faster but the actual production result is quite unpredictable. MobileLab tests show some improvements about 10-20 ms on iPhone 6.

In short, the new way is faster because it inverts the lookup order and heavily relies on actual data types (and their properties) that we use. The old approach required about 130 hash-map lookups (where the key is `std::string`) to parse a single *Props object.
The new approach prepares concrete-props-specific tables with indexes of coming values ahead of time,  iterates over raw data and puts it into those tables, and then performs a lookup in a very efficient manner.

Reviewed By: JoshuaGross

Differential Revision: D15752968

fbshipit-source-id: 847106e652eb7fc7ef7b99884a6f819ea3b9fd06
2019-06-12 21:35:21 -07:00

60 lines
1.4 KiB
C++

/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#pragma once
#include <memory>
#include <folly/dynamic.h>
#include <react/core/ConcreteComponentDescriptor.h>
#include <react/core/ConcreteShadowNode.h>
#include <react/core/LocalData.h>
#include <react/core/RawProps.h>
#include <react/core/ShadowNode.h>
using namespace facebook::react;
/**
* This defines a set of TestComponent classes: Props, ShadowNode,
* ComponentDescriptor. To be used for testing purpose.
*/
class TestLocalData : public LocalData {
public:
void setNumber(const int &number) {
number_ = number;
}
int getNumber() const {
return number_;
}
private:
int number_{0};
};
static const char TestComponentName[] = "Test";
class TestProps : public Props {
public:
using Props::Props;
};
using SharedTestProps = std::shared_ptr<const TestProps>;
class TestShadowNode;
using SharedTestShadowNode = std::shared_ptr<const TestShadowNode>;
class TestShadowNode : public ConcreteShadowNode<TestComponentName, TestProps> {
public:
using ConcreteShadowNode::ConcreteShadowNode;
};
class TestComponentDescriptor
: public ConcreteComponentDescriptor<TestShadowNode> {
public:
using ConcreteComponentDescriptor::ConcreteComponentDescriptor;
};