From bbc0c0b6ef8d570b2187773f3155b9b0d3ad8a4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hanno=20J=2E=20G=C3=B6decke?= Date: Tue, 22 Jul 2025 04:14:48 -0700 Subject: [PATCH] fix: remove redundant if checks in traceMark (#52756) Summary: There are some duplicated function calls in `PerformanceEntryReporter::reportMark()` . I know this is a micro optimization but I feel this way the code is cleaner. This is called through `performance.mark` so there is potentially a tiny little performance improvement here? ## Changelog: [INTERNAL] [FIXED] - Removed redundant checks in `PerformanceEntryReporter::reportMark()` Pull Request resolved: https://github.com/facebook/react-native/pull/52756 Test Plan: The existing testing infrastructure should cover these callsites i believe Reviewed By: rubennorte Differential Revision: D78731441 Pulled By: cortinico fbshipit-source-id: e0de12c3c6f55e12eb454ea4b7081f3d6003126c --- .../timeline/PerformanceEntryReporter.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/packages/react-native/ReactCommon/react/performance/timeline/PerformanceEntryReporter.cpp b/packages/react-native/ReactCommon/react/performance/timeline/PerformanceEntryReporter.cpp index 2f429e27d62..4263175a676 100644 --- a/packages/react-native/ReactCommon/react/performance/timeline/PerformanceEntryReporter.cpp +++ b/packages/react-native/ReactCommon/react/performance/timeline/PerformanceEntryReporter.cpp @@ -310,17 +310,16 @@ void PerformanceEntryReporter::traceMark( UserTimingDetailProvider&& detailProvider) const { auto& performanceTracer = jsinspector_modern::tracing::PerformanceTracer::getInstance(); - if (ReactPerfettoLogger::isTracing() || performanceTracer.isTracing()) { - if (ReactPerfettoLogger::isTracing()) { - ReactPerfettoLogger::mark(entry.name, entry.startTime); - } - if (performanceTracer.isTracing()) { - performanceTracer.reportMark( - entry.name, - entry.startTime, - detailProvider != nullptr ? detailProvider() : nullptr); - } + if (ReactPerfettoLogger::isTracing()) { + ReactPerfettoLogger::mark(entry.name, entry.startTime); + } + + if (performanceTracer.isTracing()) { + performanceTracer.reportMark( + entry.name, + entry.startTime, + detailProvider != nullptr ? detailProvider() : nullptr); } }