From e96a09e5ff50cccc18372fe3452352e67266cfba Mon Sep 17 00:00:00 2001 From: David Aurelio Date: Thu, 9 May 2019 04:14:08 -0700 Subject: [PATCH] **breaking:** remove `YGNodeGetInstanceCount` Summary: @public `YGNodeGetInstanceCount` was only ever meant for tests, and caused data races in multi-threaded environments. It was completely replaced with event-based counting for tests. Here we remove public API around the counter, and the counter itself. Reviewed By: SidharthGuglani Differential Revision: D15174857 fbshipit-source-id: 228e85da565bac9e8485121e956a2e41910b11c8 --- csharp/Facebook.Yoga/Native.cs | 3 --- csharp/Facebook.Yoga/YogaNode.cs | 5 ----- java/com/facebook/yoga/YogaNative.java | 1 - java/jni/YGJNI.cpp | 5 ----- javascript/sources/global.cc | 13 ------------- yoga/Yoga.cpp | 8 -------- yoga/Yoga.h | 1 - 7 files changed, 36 deletions(-) delete mode 100644 javascript/sources/global.cc diff --git a/csharp/Facebook.Yoga/Native.cs b/csharp/Facebook.Yoga/Native.cs index 7ec1ab18..3c618df0 100644 --- a/csharp/Facebook.Yoga/Native.cs +++ b/csharp/Facebook.Yoga/Native.cs @@ -43,9 +43,6 @@ namespace Facebook.Yoga [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] public static extern void YGConfigFree(IntPtr node); - [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] - public static extern int YGNodeGetInstanceCount(); - [DllImport(DllName, ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] public static extern int YGConfigGetInstanceCount(); diff --git a/csharp/Facebook.Yoga/YogaNode.cs b/csharp/Facebook.Yoga/YogaNode.cs index f681ec89..37bb3ebb 100644 --- a/csharp/Facebook.Yoga/YogaNode.cs +++ b/csharp/Facebook.Yoga/YogaNode.cs @@ -673,10 +673,5 @@ namespace Facebook.Yoga return _children != null ? ((IEnumerable)_children).GetEnumerator() : System.Linq.Enumerable.Empty().GetEnumerator(); } - - public static int GetInstanceCount() - { - return Native.YGNodeGetInstanceCount(); - } } } diff --git a/java/com/facebook/yoga/YogaNative.java b/java/com/facebook/yoga/YogaNative.java index 8b81e929..fbda3ca6 100644 --- a/java/com/facebook/yoga/YogaNative.java +++ b/java/com/facebook/yoga/YogaNative.java @@ -28,7 +28,6 @@ public class YogaNative { // YGNode related - static native int jni_YGNodeGetInstanceCount(); static native long jni_YGNodeNew(boolean useBatchingForLayoutOutputs); static native long jni_YGNodeNewWithConfig(long configPointer, boolean useBatchingForLayoutOutputs); static native void jni_YGNodeFree(long nativePointer); diff --git a/java/jni/YGJNI.cpp b/java/jni/YGJNI.cpp index 066f832f..28011661 100644 --- a/java/jni/YGJNI.cpp +++ b/java/jni/YGJNI.cpp @@ -938,10 +938,6 @@ void jni_YGNodeSetStyleInputs( YGNodeSetStyleInputs(_jlong2YGNodeRef(nativePointer), result, size); } -jint jni_YGNodeGetInstanceCount() { - return YGNodeGetInstanceCount(); -} - jlong jni_YGNodeStyleGetMargin(jlong nativePointer, jint edge) { YGNodeRef yogaNodeRef = _jlong2YGNodeRef(nativePointer); if (!YGNodeEdges{yogaNodeRef}.has(YGNodeEdges::MARGIN)) { @@ -1105,7 +1101,6 @@ jint JNI_OnLoad(JavaVM* vm, void*) { YGMakeCriticalNativeMethod(jni_YGNodeStyleSetMaxHeightPercent), YGMakeCriticalNativeMethod(jni_YGNodeStyleGetAspectRatio), YGMakeCriticalNativeMethod(jni_YGNodeStyleSetAspectRatio), - YGMakeCriticalNativeMethod(jni_YGNodeGetInstanceCount), YGMakeCriticalNativeMethod(jni_YGNodePrint), YGMakeNativeMethod(jni_YGNodeClone), YGMakeNativeMethod(jni_YGNodeSetStyleInputs), diff --git a/javascript/sources/global.cc b/javascript/sources/global.cc deleted file mode 100644 index ae8454ee..00000000 --- a/javascript/sources/global.cc +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the LICENSE - * file in the root directory of this source tree. - */ -#include - -#include "./global.hh" - -unsigned getInstanceCount(void) { - return YGNodeGetInstanceCount(); -} diff --git a/yoga/Yoga.cpp b/yoga/Yoga.cpp index 72772366..05fb10d2 100644 --- a/yoga/Yoga.cpp +++ b/yoga/Yoga.cpp @@ -206,14 +206,12 @@ void YGNodeMarkDirtyAndPropogateToDescendants(const YGNodeRef node) { return node->markDirtyAndPropogateDownwards(); } -int32_t gNodeInstanceCount = 0; int32_t gConfigInstanceCount = 0; WIN_EXPORT YGNodeRef YGNodeNewWithConfig(const YGConfigRef config) { const YGNodeRef node = new YGNode(); YGAssertWithConfig( config, node != nullptr, "Could not allocate memory for node"); - gNodeInstanceCount++; #ifdef YG_ENABLE_EVENTS Event::publish(node, {config}); #endif @@ -241,7 +239,6 @@ YGNodeRef YGNodeClone(YGNodeRef oldNode) { oldNode->getConfig(), node != nullptr, "Could not allocate memory for node"); - gNodeInstanceCount++; #ifdef YG_ENABLE_EVENTS Event::publish(node, {node->getConfig()}); #endif @@ -295,7 +292,6 @@ void YGNodeFree(const YGNodeRef node) { Event::publish(node, {node->getConfig()}); #endif delete node; - gNodeInstanceCount--; } static void YGConfigFreeRecursive(const YGNodeRef root) { @@ -337,10 +333,6 @@ void YGNodeReset(YGNodeRef node) { node->reset(); } -int32_t YGNodeGetInstanceCount(void) { - return gNodeInstanceCount; -} - int32_t YGConfigGetInstanceCount(void) { return gConfigInstanceCount; } diff --git a/yoga/Yoga.h b/yoga/Yoga.h index c616d965..a9dc01dc 100644 --- a/yoga/Yoga.h +++ b/yoga/Yoga.h @@ -62,7 +62,6 @@ WIN_EXPORT void YGNodeFreeRecursiveWithCleanupFunc( YGNodeCleanupFunc cleanup); WIN_EXPORT void YGNodeFreeRecursive(YGNodeRef node); WIN_EXPORT void YGNodeReset(YGNodeRef node); -WIN_EXPORT int32_t YGNodeGetInstanceCount(void); WIN_EXPORT void YGNodeInsertChild( YGNodeRef node,