Skip to content

Commit

Permalink
remove unused argument from RawProps (facebook#41565)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: facebook#41565

changelog: [internal]

this argument is never used, let's remove it.

Reviewed By: christophpurrer

Differential Revision: D51468580

fbshipit-source-id: aec029bc78b5490686a36ac8a5f5d0342bd28d50
  • Loading branch information
sammy-SC authored and facebook-github-bot committed Nov 21, 2023
1 parent 16ad818 commit 1e43d2b
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Props::Shared UnimplementedViewComponentDescriptor::cloneProps(
// We have to clone `Props` object one more time to make sure that we have
// an unshared (and non-`const`) copy of it which we can mutate.
RawProps emptyRawProps{};
emptyRawProps.parse(rawPropsParser_, context);
emptyRawProps.parse(rawPropsParser_);
auto unimplementedViewProps = std::make_shared<UnimplementedViewProps>(
context,
static_cast<const UnimplementedViewProps&>(*clonedProps),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class ConcreteComponentDescriptor : public ComponentDescriptor {
return ShadowNodeT::defaultSharedProps();
}

rawProps.parse(rawPropsParser_, context);
rawProps.parse(rawPropsParser_);

// Call old-style constructor
auto shadowNodeProps = ShadowNodeT::Props(context, rawProps, props);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ RawProps::RawProps(folly::dynamic dynamic) noexcept {
dynamic_ = std::move(dynamic);
}

void RawProps::parse(
const RawPropsParser& parser,
const PropsParserContext& /*unused*/) const noexcept {
void RawProps::parse(const RawPropsParser& parser) const noexcept {
react_native_assert(parser_ == nullptr && "A parser was already assigned.");
parser_ = &parser;
parser.preparse(*this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ class RawProps final {
RawProps(const RawProps& other) noexcept = delete;
RawProps& operator=(const RawProps& other) noexcept = delete;

void parse(const RawPropsParser& parser, const PropsParserContext&)
const noexcept;
void parse(const RawPropsParser& parser) const noexcept;

/*
* Deprecated. Do not use.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class RawPropsParser final {
ContextContainer contextContainer{};
PropsParserContext parserContext{-1, contextContainer};

emptyRawProps.parse(*this, parserContext);
emptyRawProps.parse(*this);
PropsT(parserContext, {}, emptyRawProps);
postPrepare();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ TEST(RawPropsTest, handleProps) {
const auto& raw = RawProps(folly::dynamic::object("nativeID", "abc"));
auto parser = RawPropsParser();
parser.prepare<Props>();
raw.parse(parser, parserContext);
raw.parse(parser);

auto props = std::make_shared<Props>(parserContext, Props(), raw);

Expand All @@ -171,7 +171,7 @@ TEST(RawPropsTest, handleRawPropsSingleString) {
const auto& raw = RawProps(folly::dynamic::object("nativeID", "abc"));
auto parser = RawPropsParser();
parser.prepare<Props>();
raw.parse(parser, parserContext);
raw.parse(parser);

std::string value = (std::string)*raw.at("nativeID", nullptr, nullptr);

Expand All @@ -186,7 +186,7 @@ TEST(RawPropsTest, handleRawPropsSingleFloat) {
RawProps(folly::dynamic::object("floatValue", (float)42.42));
auto parser = RawPropsParser();
parser.prepare<PropsSingleFloat>();
raw.parse(parser, parserContext);
raw.parse(parser);

auto value = (float)*raw.at("floatValue", nullptr, nullptr);

Expand All @@ -201,7 +201,7 @@ TEST(RawPropsTest, handleRawPropsSingleDouble) {
RawProps(folly::dynamic::object("doubleValue", (double)42.42));
auto parser = RawPropsParser();
parser.prepare<PropsSingleDouble>();
raw.parse(parser, parserContext);
raw.parse(parser);

auto value = (double)*raw.at("doubleValue", nullptr, nullptr);

Expand All @@ -215,7 +215,7 @@ TEST(RawPropsTest, handleRawPropsSingleInt) {
const auto& raw = RawProps(folly::dynamic::object("intValue", (int)42.42));
auto parser = RawPropsParser();
parser.prepare<PropsSingleInt>();
raw.parse(parser, parserContext);
raw.parse(parser);

int value = (int)*raw.at("intValue", nullptr, nullptr);

Expand All @@ -229,7 +229,7 @@ TEST(RawPropsTest, handleRawPropsSingleIntGetManyTimes) {
const auto& raw = RawProps(folly::dynamic::object("intValue", (int)42.42));
auto parser = RawPropsParser();
parser.prepare<PropsSingleInt>();
raw.parse(parser, parserContext);
raw.parse(parser);

EXPECT_EQ((int)*raw.at("intValue", nullptr, nullptr), 42);
EXPECT_EQ((int)*raw.at("intValue", nullptr, nullptr), 42);
Expand All @@ -247,7 +247,7 @@ TEST(RawPropsTest, handleRawPropsPrimitiveTypes) {

auto parser = RawPropsParser();
parser.prepare<PropsPrimitiveTypes>();
raw.parse(parser, parserContext);
raw.parse(parser);

EXPECT_EQ((int)*raw.at("intValue", nullptr, nullptr), 42);
EXPECT_NEAR((double)*raw.at("doubleValue", nullptr, nullptr), 17.42, 0.0001);
Expand All @@ -269,7 +269,7 @@ TEST(RawPropsTest, handleRawPropsPrimitiveTypesGetTwice) {

auto parser = RawPropsParser();
parser.prepare<PropsPrimitiveTypes>();
raw.parse(parser, parserContext);
raw.parse(parser);

EXPECT_EQ((int)*raw.at("intValue", nullptr, nullptr), 42);
EXPECT_NEAR((double)*raw.at("doubleValue", nullptr, nullptr), 17.42, 0.0001);
Expand Down Expand Up @@ -299,7 +299,7 @@ TEST(RawPropsTest, handleRawPropsPrimitiveTypesGetOutOfOrder) {

auto parser = RawPropsParser();
parser.prepare<PropsPrimitiveTypes>();
raw.parse(parser, parserContext);
raw.parse(parser);

EXPECT_EQ((int)*raw.at("intValue", nullptr, nullptr), 42);
EXPECT_NEAR((double)*raw.at("doubleValue", nullptr, nullptr), 17.42, 0.0001);
Expand All @@ -326,7 +326,7 @@ TEST(RawPropsTest, handleRawPropsPrimitiveTypesIncomplete) {

auto parser = RawPropsParser();
parser.prepare<PropsPrimitiveTypes>();
raw.parse(parser, parserContext);
raw.parse(parser);

EXPECT_EQ((int)*raw.at("intValue", nullptr, nullptr), 42);
EXPECT_EQ(raw.at("doubleValue", nullptr, nullptr), nullptr);
Expand All @@ -346,7 +346,7 @@ TEST(RawPropsTest, handleRawPropsPrimitiveTypesIncorrectLookup) {

auto parser = RawPropsParser();
parser.prepare<PropsPrimitiveTypes>();
raw.parse(parser, parserContext);
raw.parse(parser);

// Before D18662135, looking up an invalid key would trigger
// an infinite loop. This is out of contract, so we should only
Expand All @@ -363,7 +363,7 @@ TEST(RawPropsTest, handlePropsMultiLookup) {
const auto& raw = RawProps(folly::dynamic::object("floatValue", (float)10.0));
auto parser = RawPropsParser();
parser.prepare<PropsMultiLookup>();
raw.parse(parser, parserContext);
raw.parse(parser);

auto props = std::make_shared<PropsMultiLookup>(
parserContext, PropsMultiLookup(), raw);
Expand Down

0 comments on commit 1e43d2b

Please sign in to comment.