Skip to content

Commit

Permalink
**breaking:** remove YGNodeGetInstanceCount
Browse files Browse the repository at this point in the history
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
  • Loading branch information
davidaurelio authored and facebook-github-bot committed May 9, 2019
1 parent 9e20dfe commit e96a09e
Show file tree
Hide file tree
Showing 7 changed files with 0 additions and 36 deletions.
3 changes: 0 additions & 3 deletions csharp/Facebook.Yoga/Native.cs
Expand Up @@ -43,9 +43,6 @@ internal static class Native
[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();

Expand Down
5 changes: 0 additions & 5 deletions csharp/Facebook.Yoga/YogaNode.cs
Expand Up @@ -673,10 +673,5 @@ IEnumerator IEnumerable.GetEnumerator()
return _children != null ? ((IEnumerable<YogaNode>)_children).GetEnumerator() :
System.Linq.Enumerable.Empty<YogaNode>().GetEnumerator();
}

public static int GetInstanceCount()
{
return Native.YGNodeGetInstanceCount();
}
}
}
1 change: 0 additions & 1 deletion java/com/facebook/yoga/YogaNative.java
Expand Up @@ -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);
Expand Down
5 changes: 0 additions & 5 deletions java/jni/YGJNI.cpp
Expand Up @@ -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)) {
Expand Down Expand Up @@ -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),
Expand Down
13 changes: 0 additions & 13 deletions javascript/sources/global.cc

This file was deleted.

8 changes: 0 additions & 8 deletions yoga/Yoga.cpp
Expand Up @@ -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<Event::NodeAllocation>(node, {config});
#endif
Expand Down Expand Up @@ -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<Event::NodeAllocation>(node, {node->getConfig()});
#endif
Expand Down Expand Up @@ -295,7 +292,6 @@ void YGNodeFree(const YGNodeRef node) {
Event::publish<Event::NodeDeallocation>(node, {node->getConfig()});
#endif
delete node;
gNodeInstanceCount--;
}

static void YGConfigFreeRecursive(const YGNodeRef root) {
Expand Down Expand Up @@ -337,10 +333,6 @@ void YGNodeReset(YGNodeRef node) {
node->reset();
}

int32_t YGNodeGetInstanceCount(void) {
return gNodeInstanceCount;
}

int32_t YGConfigGetInstanceCount(void) {
return gConfigInstanceCount;
}
Expand Down
1 change: 0 additions & 1 deletion yoga/Yoga.h
Expand Up @@ -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,
Expand Down

0 comments on commit e96a09e

Please sign in to comment.