Enable Clang Tidy (#1586)
Summary: X-link: https://github.com/facebook/litho/pull/976 Pull Request resolved: https://github.com/facebook/yoga/pull/1586 X-link: https://github.com/facebook/react-native/pull/43299 Add the React Clang Tidy config to Yoga, run the auto fixes, and make some manual mechanical tweaks. Notably, the automatic changes to the infra for generating a Yoga tree from JSON capture make it 70% faster. Before: {F1463947076} After: {F1463946802} This also cleans up all the no-op shallow const parameters in headers. {F1463943386} Not all checks are available in all environments, but that is okay, as Clang Tidy will gracefully skip them. Changelog: [Internal] Reviewed By: sammy-SC Differential Revision: D54461054 fbshipit-source-id: dbd2d9ce51afd3174d1f2c6d439fa7d08baff46f
This commit is contained in:
committed by
Facebook GitHub Bot
parent
47a56db5f6
commit
b959c79a2a
@@ -26,23 +26,23 @@ Node::Node(const yoga::Config* config) : config_{config} {
|
||||
}
|
||||
}
|
||||
|
||||
Node::Node(Node&& node) {
|
||||
hasNewLayout_ = node.hasNewLayout_;
|
||||
isReferenceBaseline_ = node.isReferenceBaseline_;
|
||||
isDirty_ = node.isDirty_;
|
||||
alwaysFormsContainingBlock_ = node.alwaysFormsContainingBlock_;
|
||||
nodeType_ = node.nodeType_;
|
||||
context_ = node.context_;
|
||||
measureFunc_ = node.measureFunc_;
|
||||
baselineFunc_ = node.baselineFunc_;
|
||||
dirtiedFunc_ = node.dirtiedFunc_;
|
||||
style_ = node.style_;
|
||||
layout_ = node.layout_;
|
||||
lineIndex_ = node.lineIndex_;
|
||||
owner_ = node.owner_;
|
||||
children_ = std::move(node.children_);
|
||||
config_ = node.config_;
|
||||
resolvedDimensions_ = node.resolvedDimensions_;
|
||||
Node::Node(Node&& node) noexcept
|
||||
: hasNewLayout_(node.hasNewLayout_),
|
||||
isReferenceBaseline_(node.isReferenceBaseline_),
|
||||
isDirty_(node.isDirty_),
|
||||
alwaysFormsContainingBlock_(node.alwaysFormsContainingBlock_),
|
||||
nodeType_(node.nodeType_),
|
||||
context_(node.context_),
|
||||
measureFunc_(node.measureFunc_),
|
||||
baselineFunc_(node.baselineFunc_),
|
||||
dirtiedFunc_(node.dirtiedFunc_),
|
||||
style_(std::move(node.style_)),
|
||||
layout_(node.layout_),
|
||||
lineIndex_(node.lineIndex_),
|
||||
owner_(node.owner_),
|
||||
children_(std::move(node.children_)),
|
||||
config_(node.config_),
|
||||
resolvedDimensions_(node.resolvedDimensions_) {
|
||||
for (auto c : children_) {
|
||||
c->setOwner(this);
|
||||
}
|
||||
@@ -83,7 +83,7 @@ void Node::setMeasureFunc(YGMeasureFunc measureFunc) {
|
||||
} else {
|
||||
yoga::assertFatalWithNode(
|
||||
this,
|
||||
children_.size() == 0,
|
||||
children_.empty(),
|
||||
"Cannot set measure function: Nodes with measure functions cannot have "
|
||||
"children.");
|
||||
// TODO: t18095186 Move nodeType to opt-in function and mark appropriate
|
||||
@@ -122,18 +122,17 @@ void Node::setConfig(yoga::Config* config) {
|
||||
}
|
||||
|
||||
void Node::setDirty(bool isDirty) {
|
||||
if (isDirty == isDirty_) {
|
||||
if (static_cast<int>(isDirty) == isDirty_) {
|
||||
return;
|
||||
}
|
||||
isDirty_ = isDirty;
|
||||
if (isDirty && dirtiedFunc_) {
|
||||
if (isDirty && (dirtiedFunc_ != nullptr)) {
|
||||
dirtiedFunc_(this);
|
||||
}
|
||||
}
|
||||
|
||||
bool Node::removeChild(Node* child) {
|
||||
std::vector<Node*>::iterator p =
|
||||
std::find(children_.begin(), children_.end(), child);
|
||||
auto p = std::find(children_.begin(), children_.end(), child);
|
||||
if (p != children_.end()) {
|
||||
children_.erase(p);
|
||||
return true;
|
||||
@@ -307,7 +306,7 @@ void Node::markDirtyAndPropagate() {
|
||||
if (!isDirty_) {
|
||||
setDirty(true);
|
||||
setLayoutComputedFlexBasis(FloatOptional());
|
||||
if (owner_) {
|
||||
if (owner_ != nullptr) {
|
||||
owner_->markDirtyAndPropagate();
|
||||
}
|
||||
}
|
||||
@@ -351,7 +350,7 @@ bool Node::isNodeFlexible() {
|
||||
void Node::reset() {
|
||||
yoga::assertFatalWithNode(
|
||||
this,
|
||||
children_.size() == 0,
|
||||
children_.empty(),
|
||||
"Cannot reset a node which still has children attached");
|
||||
yoga::assertFatalWithNode(
|
||||
this, owner_ == nullptr, "Cannot reset a node still attached to a owner");
|
||||
|
Reference in New Issue
Block a user