From 6cc5137a072cf79e0cae2d9416ed9bc616570843 Mon Sep 17 00:00:00 2001 From: Eric Schlanger Date: Wed, 13 Mar 2019 07:25:13 -0700 Subject: [PATCH] Exclude logging functionality outside debug builds Summary: Don't compile in YGNodePrint in production builds Reviewed By: davidaurelio Differential Revision: D14258269 fbshipit-source-id: 15b5e94d241a752fea74a45263aa343265071451 --- ReactAndroid/src/main/jni/first-party/yogajni/jni/YGJNI.cpp | 2 ++ ReactCommon/yoga/yoga/YGNodePrint.cpp | 2 ++ ReactCommon/yoga/yoga/YGNodePrint.h | 2 ++ ReactCommon/yoga/yoga/Yoga.cpp | 6 ++++++ 4 files changed, 12 insertions(+) diff --git a/ReactAndroid/src/main/jni/first-party/yogajni/jni/YGJNI.cpp b/ReactAndroid/src/main/jni/first-party/yogajni/jni/YGJNI.cpp index 0cd97be88..cf923dc8a 100644 --- a/ReactAndroid/src/main/jni/first-party/yogajni/jni/YGJNI.cpp +++ b/ReactAndroid/src/main/jni/first-party/yogajni/jni/YGJNI.cpp @@ -352,11 +352,13 @@ void jni_YGNodeReset(jlong nativePointer) { } void jni_YGNodePrint(jlong nativePointer) { +#ifdef DEBUG const YGNodeRef node = _jlong2YGNodeRef(nativePointer); YGNodePrint( node, (YGPrintOptions)( YGPrintOptionsStyle | YGPrintOptionsLayout | YGPrintOptionsChildren)); +#endif } void jni_YGNodeInsertChild( diff --git a/ReactCommon/yoga/yoga/YGNodePrint.cpp b/ReactCommon/yoga/yoga/YGNodePrint.cpp index 5dbd214f1..ee07ac928 100644 --- a/ReactCommon/yoga/yoga/YGNodePrint.cpp +++ b/ReactCommon/yoga/yoga/YGNodePrint.cpp @@ -4,6 +4,7 @@ * This source code is licensed under the MIT license found in the LICENSE * file in the root directory of this source tree. */ +#ifdef DEBUG #include "YGNodePrint.h" #include #include "YGEnums.h" @@ -230,3 +231,4 @@ void YGNodeToString( } } // namespace yoga } // namespace facebook +#endif diff --git a/ReactCommon/yoga/yoga/YGNodePrint.h b/ReactCommon/yoga/yoga/YGNodePrint.h index 9615bf8e5..13cf367b5 100644 --- a/ReactCommon/yoga/yoga/YGNodePrint.h +++ b/ReactCommon/yoga/yoga/YGNodePrint.h @@ -4,6 +4,7 @@ * This source code is licensed under the MIT license found in the LICENSE * file in the root directory of this source tree. */ +#ifdef DEBUG #pragma once #include @@ -20,3 +21,4 @@ void YGNodeToString( } // namespace yoga } // namespace facebook +#endif diff --git a/ReactCommon/yoga/yoga/Yoga.cpp b/ReactCommon/yoga/yoga/Yoga.cpp index 94d9a602a..819039912 100644 --- a/ReactCommon/yoga/yoga/Yoga.cpp +++ b/ReactCommon/yoga/yoga/Yoga.cpp @@ -979,6 +979,7 @@ bool YGLayoutNodeInternal( YGMarkerLayoutData& layoutMarkerData, void* const layoutContext); +#ifdef DEBUG static void YGNodePrintInternal( const YGNodeRef node, const YGPrintOptions options) { @@ -990,6 +991,7 @@ static void YGNodePrintInternal( void YGNodePrint(const YGNodeRef node, const YGPrintOptions options) { YGNodePrintInternal(node, options); } +#endif const std::array leading = { {YGEdgeTop, YGEdgeBottom, YGEdgeLeft, YGEdgeRight}}; @@ -4091,6 +4093,7 @@ void YGNodeCalculateLayoutWithContext( node->getLayout().direction, ownerWidth, ownerHeight, ownerWidth); YGRoundToPixelGrid(node, node->getConfig()->pointScaleFactor, 0.0f, 0.0f); +#ifdef DEBUG if (node->getConfig()->printTree) { YGNodePrint( node, @@ -4098,6 +4101,7 @@ void YGNodeCalculateLayoutWithContext( YGPrintOptionsLayout | YGPrintOptionsChildren | YGPrintOptionsStyle)); } +#endif } // We want to get rid off `useLegacyStretchBehaviour` from YGConfig. But we @@ -4147,6 +4151,7 @@ void YGNodeCalculateLayoutWithContext( !originalNode->isLayoutTreeEqualToNode(*node); node->setLayoutDoesLegacyFlagAffectsLayout(neededLegacyStretchBehaviour); +#ifdef DEBUG if (originalNode->getConfig()->printTree) { YGNodePrint( originalNode, @@ -4154,6 +4159,7 @@ void YGNodeCalculateLayoutWithContext( YGPrintOptionsLayout | YGPrintOptionsChildren | YGPrintOptionsStyle)); } +#endif } YGConfigFreeRecursive(originalNode); YGNodeFreeRecursive(originalNode);