Skip to content

Commit 1d7a24f

Browse files
davidaureliofacebook-github-bot
authored andcommitted
inline trivial constructors / methods
Summary: @public inlines some trivial constructors, destructors, and methods. Reviewed By: astreet Differential Revision: D8912691 fbshipit-source-id: 79840ef3322676deebed99391390d6c1796963b5
1 parent dfc7b2f commit 1d7a24f

File tree

6 files changed

+28
-61
lines changed

6 files changed

+28
-61
lines changed

ReactCommon/yoga/yoga/YGLayout.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,3 @@ bool YGLayout::operator==(YGLayout layout) const {
6161

6262
return isEqual;
6363
}
64-
65-
bool YGLayout::operator!=(YGLayout layout) const {
66-
return !(*this == layout);
67-
}

ReactCommon/yoga/yoga/YGLayout.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,7 @@ struct YGLayout {
3838
YGLayout();
3939

4040
bool operator==(YGLayout layout) const;
41-
bool operator!=(YGLayout layout) const;
41+
bool operator!=(YGLayout layout) const {
42+
return !(*this == layout);
43+
}
4244
};

ReactCommon/yoga/yoga/YGNode.cpp

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -254,29 +254,6 @@ void YGNode::setPosition(
254254
trailing[crossAxis]);
255255
}
256256

257-
YGNode::YGNode()
258-
: context_(nullptr),
259-
print_(nullptr),
260-
hasNewLayout_(true),
261-
nodeType_(YGNodeTypeDefault),
262-
measure_(nullptr),
263-
baseline_(nullptr),
264-
dirtied_(nullptr),
265-
style_(YGStyle()),
266-
layout_(YGLayout()),
267-
lineIndex_(0),
268-
owner_(nullptr),
269-
children_(YGVector()),
270-
config_(nullptr),
271-
isDirty_(false),
272-
resolvedDimensions_({{YGValueUndefined, YGValueUndefined}}) {}
273-
274-
YGNode::YGNode(const YGNode& node) = default;
275-
276-
YGNode::YGNode(const YGConfigRef newConfig) : YGNode() {
277-
config_ = newConfig;
278-
}
279-
280257
YGNode& YGNode::operator=(const YGNode& node) {
281258
if (&node == this) {
282259
return *this;
@@ -360,11 +337,6 @@ void YGNode::clearChildren() {
360337
children_.shrink_to_fit();
361338
}
362339

363-
YGNode::~YGNode() {
364-
// All the member variables are deallocated externally, so no need to
365-
// deallocate here
366-
}
367-
368340
// Other Methods
369341

370342
void YGNode::cloneChildrenIfNeeded() {

ReactCommon/yoga/yoga/YGNode.h

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,31 +14,32 @@
1414

1515
struct YGNode {
1616
private:
17-
void* context_;
18-
YGPrintFunc print_;
19-
bool hasNewLayout_;
20-
YGNodeType nodeType_;
21-
YGMeasureFunc measure_;
22-
YGBaselineFunc baseline_;
23-
YGDirtiedFunc dirtied_;
24-
YGStyle style_;
25-
YGLayout layout_;
26-
uint32_t lineIndex_;
27-
YGNodeRef owner_;
28-
YGVector children_;
29-
YGConfigRef config_;
30-
bool isDirty_;
31-
std::array<YGValue, 2> resolvedDimensions_;
17+
void* context_ = nullptr;
18+
YGPrintFunc print_ = nullptr;
19+
bool hasNewLayout_ = true;
20+
YGNodeType nodeType_ = YGNodeTypeDefault;
21+
YGMeasureFunc measure_ = nullptr;
22+
YGBaselineFunc baseline_ = nullptr;
23+
YGDirtiedFunc dirtied_ = nullptr;
24+
YGStyle style_ = {};
25+
YGLayout layout_ = {};
26+
uint32_t lineIndex_ = 0;
27+
YGNodeRef owner_ = nullptr;
28+
YGVector children_ = {};
29+
YGConfigRef config_ = nullptr;
30+
bool isDirty_ = false;
31+
std::array<YGValue, 2> resolvedDimensions_ = {
32+
{YGValueUndefined, YGValueUndefined}};
3233

3334
YGFloatOptional relativePosition(
3435
const YGFlexDirection& axis,
3536
const float& axisSize) const;
3637

3738
public:
38-
YGNode();
39-
~YGNode();
40-
explicit YGNode(const YGConfigRef newConfig);
41-
YGNode(const YGNode& node);
39+
YGNode() = default;
40+
~YGNode() = default; // cleanup of owner/children relationships in YGNodeFree
41+
explicit YGNode(const YGConfigRef newConfig) : config_(newConfig){};
42+
YGNode(const YGNode& node) = default;
4243
YGNode& operator=(const YGNode& node);
4344

4445
// Getters

ReactCommon/yoga/yoga/YGStyle.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,3 @@ bool YGStyle::operator==(const YGStyle& style) {
9898

9999
return areNonFloatValuesEqual;
100100
}
101-
102-
bool YGStyle::operator!=(YGStyle style) {
103-
return !(*this == style);
104-
}
105-
106-
YGStyle::~YGStyle() {}

ReactCommon/yoga/yoga/YGStyle.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,14 @@ struct YGStyle {
3232
std::array<YGValue, 2> dimensions;
3333
std::array<YGValue, 2> minDimensions;
3434
std::array<YGValue, 2> maxDimensions;
35+
// Yoga specific properties, not compatible with flexbox specification
3536
YGFloatOptional aspectRatio;
3637

3738
YGStyle();
38-
// Yoga specific properties, not compatible with flexbox specification
3939
bool operator==(const YGStyle& style);
4040

41-
bool operator!=(YGStyle style);
42-
~YGStyle();
41+
bool operator!=(YGStyle style) {
42+
return !(*this == style);
43+
}
44+
~YGStyle() = default;
4345
};

0 commit comments

Comments
 (0)