diff --git a/yoga/YGNode.cpp b/yoga/YGNode.cpp
index 303df5bc..77000b5c 100644
--- a/yoga/YGNode.cpp
+++ b/yoga/YGNode.cpp
@@ -12,6 +12,12 @@
using namespace facebook;
using facebook::yoga::detail::CompactValue;
+void YGNode::print() {
+ if (print_ != nullptr) {
+ print_(this);
+ }
+}
+
YGFloatOptional YGNode::getLeadingPosition(
const YGFlexDirection axis,
const float axisSize) const {
@@ -298,7 +304,7 @@ YGNode& YGNode::operator=(const YGNode& node) {
}
context_ = node.getContext();
- print_ = node.getPrintFunc();
+ print_ = node.print_;
hasNewLayout_ = node.getHasNewLayout();
nodeType_ = node.getNodeType();
measureUsesContext_ = node.measureUsesContext_;
diff --git a/yoga/YGNode.h b/yoga/YGNode.h
index ddb5fa07..14bc6639 100644
--- a/yoga/YGNode.h
+++ b/yoga/YGNode.h
@@ -68,9 +68,7 @@ public:
return context_;
}
- YGPrintFunc getPrintFunc() const {
- return print_;
- }
+ void print();
bool getHasNewLayout() const {
return hasNewLayout_;
diff --git a/yoga/YGNodePrint.cpp b/yoga/YGNodePrint.cpp
index 5e51a405..a4db36f2 100644
--- a/yoga/YGNodePrint.cpp
+++ b/yoga/YGNodePrint.cpp
@@ -114,9 +114,7 @@ void YGNodeToString(
uint32_t level) {
indent(str, level);
appendFormatedString(str, "
getPrintFunc() != nullptr) {
- node->getPrintFunc()(node);
- }
+ node->print();
if (options & YGPrintOptionsLayout) {
appendFormatedString(str, "layout=\"");
diff --git a/yoga/Yoga.cpp b/yoga/Yoga.cpp
index 98f78e6b..c87f776d 100644
--- a/yoga/Yoga.cpp
+++ b/yoga/Yoga.cpp
@@ -169,10 +169,6 @@ void YGNodeSetDirtiedFunc(YGNodeRef node, YGDirtiedFunc dirtiedFunc) {
node->setDirtiedFunc(dirtiedFunc);
}
-YGPrintFunc YGNodeGetPrintFunc(YGNodeRef node) {
- return node->getPrintFunc();
-}
-
void YGNodeSetPrintFunc(YGNodeRef node, YGPrintFunc printFunc) {
node->setPrintFunc(printFunc);
}
@@ -3847,9 +3843,7 @@ bool YGLayoutNodeInternal(
"%s%d.{[skipped] ",
YGSpacer(gDepth),
gDepth);
- if (node->getPrintFunc() != nullptr) {
- node->getPrintFunc()(node);
- }
+ node->print();
Log::log(
node,
YGLogLevelVerbose,
@@ -3873,9 +3867,7 @@ bool YGLayoutNodeInternal(
YGSpacer(gDepth),
gDepth,
needToVisitNode ? "*" : "");
- if (node->getPrintFunc() != nullptr) {
- node->getPrintFunc()(node);
- }
+ node->print();
Log::log(
node,
YGLogLevelVerbose,
@@ -3911,9 +3903,7 @@ bool YGLayoutNodeInternal(
YGSpacer(gDepth),
gDepth,
needToVisitNode ? "*" : "");
- if (node->getPrintFunc() != nullptr) {
- node->getPrintFunc()(node);
- }
+ node->print();
Log::log(
node,
YGLogLevelVerbose,
diff --git a/yoga/Yoga.h b/yoga/Yoga.h
index 86aa152a..753a2f9f 100644
--- a/yoga/Yoga.h
+++ b/yoga/Yoga.h
@@ -138,7 +138,6 @@ bool YGNodeHasBaselineFunc(YGNodeRef node);
void YGNodeSetBaselineFunc(YGNodeRef node, YGBaselineFunc baselineFunc);
YGDirtiedFunc YGNodeGetDirtiedFunc(YGNodeRef node);
void YGNodeSetDirtiedFunc(YGNodeRef node, YGDirtiedFunc dirtiedFunc);
-YGPrintFunc YGNodeGetPrintFunc(YGNodeRef node);
void YGNodeSetPrintFunc(YGNodeRef node, YGPrintFunc printFunc);
WIN_EXPORT bool YGNodeGetHasNewLayout(YGNodeRef node);
WIN_EXPORT void YGNodeSetHasNewLayout(YGNodeRef node, bool hasNewLayout);