From ead669ade31ee703c407f96c0ce98d8f2991bdc8 Mon Sep 17 00:00:00 2001 From: Christoph Purrer Date: Mon, 7 Jul 2025 11:04:01 -0700 Subject: [PATCH] Remove unused ReactCommon/TurboModuleUtils functions #deepCopyJSIObject and #deepCopyJSIArray (#52443) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/52443 Changelog: [General][Breaking] Remove unused ReactCommon/TurboModuleUtils functions #deepCopyJSIObject and #deepCopyJSIArray Those are not used anymore Reviewed By: cortinico Differential Revision: D77771186 fbshipit-source-id: e1f5e34238567241b4204d58ff85fd9067e321df --- .../core/ReactCommon/TurboModuleUtils.cpp | 53 ------------------- .../core/ReactCommon/TurboModuleUtils.h | 10 ++-- 2 files changed, 3 insertions(+), 60 deletions(-) diff --git a/packages/react-native/ReactCommon/react/nativemodule/core/ReactCommon/TurboModuleUtils.cpp b/packages/react-native/ReactCommon/react/nativemodule/core/ReactCommon/TurboModuleUtils.cpp index 2a7bbb51429..c3915063a6a 100644 --- a/packages/react-native/ReactCommon/react/nativemodule/core/ReactCommon/TurboModuleUtils.cpp +++ b/packages/react-native/ReactCommon/react/nativemodule/core/ReactCommon/TurboModuleUtils.cpp @@ -9,59 +9,6 @@ namespace facebook::react { -static jsi::Value deepCopyJSIValue(jsi::Runtime& rt, const jsi::Value& value) { - if (value.isNull()) { - return jsi::Value::null(); - } - - if (value.isBool()) { - return jsi::Value(value.getBool()); - } - - if (value.isNumber()) { - return jsi::Value(value.getNumber()); - } - - if (value.isString()) { - return value.getString(rt); - } - - if (value.isObject()) { - jsi::Object o = value.getObject(rt); - if (o.isArray(rt)) { - return deepCopyJSIArray(rt, o.getArray(rt)); - } - if (o.isFunction(rt)) { - return o.getFunction(rt); - } - return deepCopyJSIObject(rt, o); - } - - return jsi::Value::undefined(); -} - -jsi::Object deepCopyJSIObject(jsi::Runtime& rt, const jsi::Object& obj) { - jsi::Object copy(rt); - jsi::Array propertyNames = obj.getPropertyNames(rt); - size_t size = propertyNames.size(rt); - for (size_t i = 0; i < size; i++) { - jsi::String name = propertyNames.getValueAtIndex(rt, i).getString(rt); - jsi::Value value = obj.getProperty(rt, name); - copy.setProperty(rt, name, deepCopyJSIValue(rt, value)); - } - return copy; -} - -jsi::Array deepCopyJSIArray(jsi::Runtime& rt, const jsi::Array& arr) { - size_t size = arr.size(rt); - jsi::Array copy(rt, size); - for (size_t i = 0; i < size; i++) { - copy.setValueAtIndex( - rt, i, deepCopyJSIValue(rt, arr.getValueAtIndex(rt, i))); - } - return copy; -} - Promise::Promise(jsi::Runtime& rt, jsi::Function resolve, jsi::Function reject) : LongLivedObject(rt), resolve_(std::move(resolve)), diff --git a/packages/react-native/ReactCommon/react/nativemodule/core/ReactCommon/TurboModuleUtils.h b/packages/react-native/ReactCommon/react/nativemodule/core/ReactCommon/TurboModuleUtils.h index 005fc1504ef..704116f97eb 100644 --- a/packages/react-native/ReactCommon/react/nativemodule/core/ReactCommon/TurboModuleUtils.h +++ b/packages/react-native/ReactCommon/react/nativemodule/core/ReactCommon/TurboModuleUtils.h @@ -7,18 +7,14 @@ #pragma once +#include +#include #include +#include #include -#include -#include -#include - namespace facebook::react { -jsi::Object deepCopyJSIObject(jsi::Runtime& rt, const jsi::Object& obj); -jsi::Array deepCopyJSIArray(jsi::Runtime& rt, const jsi::Array& arr); - struct Promise : public LongLivedObject { Promise(jsi::Runtime& rt, jsi::Function resolve, jsi::Function reject);