Skip to content

Commit bcb482f

Browse files
dfhmetameta-codesync[bot]
authored andcommitted
getDirectManipulationAllowlist should return by const reference to avoid per-frame copies (#55295)
Summary: Pull Request resolved: #55295 Fix a memory allocation hotspot with getDirectManipulationAllowlist(). Function was returning a static std::unordered_set<std::string> by value instead of by const reference, causing the set to be copied each call. The fix changes the return type from std::unordered_set<std::string> to const std::unordered_set<std::string>&, eliminating the per-frame copy overhead entirely. Changelog: [Internal] Reviewed By: javache, rozele Differential Revision: D91475194 fbshipit-source-id: 0c438d0f1c1d202e5d665edf26a144c9ffdeaeb0
1 parent f046599 commit bcb482f

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

packages/react-native/ReactCommon/react/renderer/animated/internal/NativeAnimatedAllowlist.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@
1212

1313
namespace facebook::react {
1414

15-
inline static std::unordered_set<std::string> getDirectManipulationAllowlist()
15+
inline const std::unordered_set<std::string> &getDirectManipulationAllowlist()
1616
{
1717
/**
1818
* Direct manipulation eligible styles allowed by the NativeAnimated JS
1919
* implementation. Keep in sync with
2020
* packages/react-native/Libraries/Animated/NativeAnimatedAllowlist.js
2121
*/
22-
static std::unordered_set<std::string> DIRECT_MANIPULATION_STYLES{
22+
static const std::unordered_set<std::string> DIRECT_MANIPULATION_STYLES{
2323
/* SUPPORTED_COLOR_STYLES */
2424
"backgroundColor",
2525
"borderBottomColor",

0 commit comments

Comments
 (0)