From 3f98c8e4c2c8f40b81c1a90aa65c1bdc9327faed Mon Sep 17 00:00:00 2001 From: NikoAri Date: Wed, 13 Apr 2022 16:26:55 -0700 Subject: [PATCH] Avoid full copy of large folly::dynamic objects by switching to std::move semantics (#33621) Summary: Problem: Current creation of ModuleConfig does a full copy of folly::dynamic object, which for large objects can cause 1000's of memory allocations, and thus increasing app's memory footprint and speed. Fix: Use std::move semantics to avoid copy of folly::dynamic, thus avoiding memory allocations. ## Changelog [General] [Fixed] - Avoid full copy of large folly::dynamic objects by switching to std::move semantics Pull Request resolved: https://github.com/facebook/react-native/pull/33621 Test Plan: Compiled React Native for Windows Consumed into Microsoft Excel App Tested functionality through Microsoft Office Excel App Viewed Memory Allocations in Debugger Reviewed By: cortinico Differential Revision: D35599759 Pulled By: RSNara fbshipit-source-id: 095a961422cca4655590d2283f6955472f1f0410 --- ReactCommon/cxxreact/ModuleRegistry.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ReactCommon/cxxreact/ModuleRegistry.cpp b/ReactCommon/cxxreact/ModuleRegistry.cpp index ecc88c2ef5d540..5a0221b02f9f87 100644 --- a/ReactCommon/cxxreact/ModuleRegistry.cpp +++ b/ReactCommon/cxxreact/ModuleRegistry.cpp @@ -189,7 +189,7 @@ folly::Optional ModuleRegistry::getConfig( // no constants or methods return folly::none; } else { - return ModuleConfig{index, config}; + return ModuleConfig{index, std::move(config)}; } }