Remove YGNodeSetPrintFunc and related (#1553)

Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1553

X-link: https://github.com/facebook/react-native/pull/42274

Separate from `YGConfigSetPrintTreeFlag` we have a public API `YGNodeSetPrintFunc` which sets a function called, if you manually change a constant in source code during debugging.

This is not debug-only, is exposed as part of the public API (without a way to turn it on from the public API), and takes up a pointer per node doing nothing.

I'm not aware of anyone recently using the capability, and the tracing/event related work done since then would be more powerful for this anyway.

Remove the API.

Changelog: [Internal]

Reviewed By: rozele

Differential Revision: D52767445

fbshipit-source-id: f72927b47cffa4fe6fe886b42f07cc1ba55f141e
This commit is contained in:
Nick Gerleman
2024-01-16 10:07:19 -08:00
committed by Facebook GitHub Bot
parent 508df05f0d
commit 0bbfe4503d
5 changed files with 2 additions and 121 deletions

View File

@@ -2097,35 +2097,6 @@ static void calculateLayoutImpl(
}
}
bool gPrintChanges = false;
bool gPrintSkips = false;
static const char* spacer =
" ";
static const char* spacerWithLength(const unsigned long level) {
const size_t spacerLen = strlen(spacer);
if (level > spacerLen) {
return &spacer[0];
} else {
return &spacer[spacerLen - level];
}
}
static const char* sizingModeName(
const SizingMode mode,
const bool performLayout) {
switch (mode) {
case SizingMode::MaxContent:
return performLayout ? "LAY_UNDEFINED" : "UNDEFINED";
case SizingMode::StretchFit:
return performLayout ? "LAY_EXACTLY" : "EXACTLY";
case SizingMode::FitContent:
return performLayout ? "LAY_AT_MOST" : "AT_MOST";
}
return "";
}
//
// This is a wrapper around the calculateLayoutImpl function. It determines
// whether the layout request is redundant and can be skipped.
@@ -2252,48 +2223,7 @@ bool calculateLayoutInternal(
(performLayout ? layoutMarkerData.cachedLayouts
: layoutMarkerData.cachedMeasures) += 1;
if (gPrintChanges && gPrintSkips) {
yoga::log(
node,
LogLevel::Verbose,
"%s%d.{[skipped] ",
spacerWithLength(depth),
depth);
node->print();
yoga::log(
node,
LogLevel::Verbose,
"wm: %s, hm: %s, aw: %f ah: %f => d: (%f, %f) %s\n",
sizingModeName(widthSizingMode, performLayout),
sizingModeName(heightSizingMode, performLayout),
availableWidth,
availableHeight,
cachedResults->computedWidth,
cachedResults->computedHeight,
LayoutPassReasonToString(reason));
}
} else {
if (gPrintChanges) {
yoga::log(
node,
LogLevel::Verbose,
"%s%d.{%s",
spacerWithLength(depth),
depth,
needToVisitNode ? "*" : "");
node->print();
yoga::log(
node,
LogLevel::Verbose,
"wm: %s, hm: %s, aw: %f ah: %f %s\n",
sizingModeName(widthSizingMode, performLayout),
sizingModeName(heightSizingMode, performLayout),
availableWidth,
availableHeight,
LayoutPassReasonToString(reason));
}
calculateLayoutImpl(
node,
availableWidth,
@@ -2309,26 +2239,6 @@ bool calculateLayoutInternal(
generationCount,
reason);
if (gPrintChanges) {
yoga::log(
node,
LogLevel::Verbose,
"%s%d.}%s",
spacerWithLength(depth),
depth,
needToVisitNode ? "*" : "");
node->print();
yoga::log(
node,
LogLevel::Verbose,
"wm: %s, hm: %s, d: (%f, %f) %s\n",
sizingModeName(widthSizingMode, performLayout),
sizingModeName(heightSizingMode, performLayout),
layout->measuredDimension(Dimension::Width),
layout->measuredDimension(Dimension::Height),
LayoutPassReasonToString(reason));
}
layout->lastOwnerDirection = ownerDirection;
if (cachedResults == nullptr) {
@@ -2338,9 +2248,6 @@ bool calculateLayoutInternal(
if (layout->nextCachedMeasurementsIndex ==
LayoutResults::MaxCachedMeasurements) {
if (gPrintChanges) {
yoga::log(node, LogLevel::Verbose, "Out of cache entries!\n");
}
layout->nextCachedMeasurementsIndex = 0;
}