From 4d85e112a33518f64f7d76c904884ba5abc2587b Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Tue, 22 Aug 2023 06:35:14 -0700 Subject: [PATCH] Delete use of folly::function (#39093) Summary: Changelog: [internal] Pull Request resolved: https://github.com/facebook/react-native/pull/39093 I was looking at Folly containers and found we were using folly::function. According to the compiler, we don't need it. It should fail during build time if its properties were needed. Documentation for folly function: https://github.com/facebook/folly/blob/main/folly/docs/Function.md Reviewed By: christophpurrer Differential Revision: D48519164 fbshipit-source-id: 88002ca3a1302db2a397fc7f5e3cae354669a9ff --- .../ReactCommon/butter/function.h | 51 ------------------- .../ReactCommon/react/bridging/Base.h | 5 +- .../ReactCommon/react/bridging/Function.h | 17 +++---- .../android/ReactCommon/JavaTurboModule.cpp | 1 - 4 files changed, 9 insertions(+), 65 deletions(-) delete mode 100644 packages/react-native/ReactCommon/butter/function.h diff --git a/packages/react-native/ReactCommon/butter/function.h b/packages/react-native/ReactCommon/butter/function.h deleted file mode 100644 index 724752498f8..00000000000 --- a/packages/react-native/ReactCommon/butter/function.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#pragma once - -#include - -#if ( \ - defined(BUTTER_FUNCTION_OVERRIDE_INCLUDE) && \ - defined(BUTTER_FUNCTION_OVERRIDE)) - -#include BUTTER_FUNCTION_OVERRIDE_INCLUDE - -#elif defined(BUTTER_USE_FOLLY_CONTAINERS) - -#include - -#else - -#include - -#endif - -namespace facebook { -namespace butter { - -#if ( \ - defined(BUTTER_FUNCTION_OVERRIDE_INCLUDE) && \ - defined(BUTTER_FUNCTION_OVERRIDE)) - -template -using function = BUTTER_FUNCTION_OVERRIDE; - -#elif defined(BUTTER_USE_FOLLY_CONTAINERS) - -template -using function = folly::Function; - -#else - -template -using function = std::function; - -#endif - -} // namespace butter -} // namespace facebook diff --git a/packages/react-native/ReactCommon/react/bridging/Base.h b/packages/react-native/ReactCommon/react/bridging/Base.h index 4ff8ef3a8e4..0de8aa19e7b 100644 --- a/packages/react-native/ReactCommon/react/bridging/Base.h +++ b/packages/react-native/ReactCommon/react/bridging/Base.h @@ -10,7 +10,6 @@ #include #include -#include #include #include @@ -36,12 +35,12 @@ struct function_wrapper; template struct function_wrapper { - using type = butter::function; + using type = std::function; }; template struct function_wrapper { - using type = butter::function; + using type = std::function; }; template diff --git a/packages/react-native/ReactCommon/react/bridging/Function.h b/packages/react-native/ReactCommon/react/bridging/Function.h index 568dd59acba..b1ba9520313 100644 --- a/packages/react-native/ReactCommon/react/bridging/Function.h +++ b/packages/react-native/ReactCommon/react/bridging/Function.h @@ -12,8 +12,6 @@ #include -#include - namespace facebook::react { template @@ -169,8 +167,8 @@ struct Bridging> { }; template -struct Bridging> { - using Func = butter::function; +struct Bridging> { + using Func = std::function; using IndexSequence = std::index_sequence_for; static constexpr size_t kArgumentCount = sizeof...(Args); @@ -219,15 +217,14 @@ struct Bridging> { template struct Bridging< std::function, - std::enable_if_t, - butter::function>>> - : Bridging> {}; + std::enable_if_t< + !std::is_same_v, std::function>>> + : Bridging> {}; template -struct Bridging : Bridging> {}; +struct Bridging : Bridging> {}; template -struct Bridging : Bridging> {}; +struct Bridging : Bridging> {}; } // namespace facebook::react diff --git a/packages/react-native/ReactCommon/react/nativemodule/core/platform/android/ReactCommon/JavaTurboModule.cpp b/packages/react-native/ReactCommon/react/nativemodule/core/platform/android/ReactCommon/JavaTurboModule.cpp index 0940a6ea48a..138e1d817ab 100644 --- a/packages/react-native/ReactCommon/react/nativemodule/core/platform/android/ReactCommon/JavaTurboModule.cpp +++ b/packages/react-native/ReactCommon/react/nativemodule/core/platform/android/ReactCommon/JavaTurboModule.cpp @@ -16,7 +16,6 @@ #include #include #include -#include #include #include #include