Skip to content

Commit

Permalink
Avoid full copy of large folly::dynamic objects by switching to std::…
Browse files Browse the repository at this point in the history
…move semantics (facebook#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: facebook#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
  • Loading branch information
NikoAri authored and Saadnajmi committed Jan 14, 2023
1 parent 40662fe commit a01340b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion ReactCommon/cxxreact/ModuleRegistry.cpp
Expand Up @@ -189,7 +189,7 @@ folly::Optional<ModuleConfig> ModuleRegistry::getConfig(
// no constants or methods
return folly::none;
} else {
return ModuleConfig{index, config};
return ModuleConfig{index, std::move(config)};
}
}

Expand Down

0 comments on commit a01340b

Please sign in to comment.