mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Avoid unnecessary copy of view props map in UIManager::updateShadowTree (#52908)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/52908 ## Changelog: [General] [Changed] - Avoid unnecessary copy of view props map in UIManager::updateShadowTree Reviewed By: christophpurrer Differential Revision: D79193215 fbshipit-source-id: 6a55dc2bf3bcf95eebeeddf2d747fe11ae56bf78
This commit is contained in:
committed by
Facebook GitHub Bot
parent
2dd72f956b
commit
5b38bb4745
@@ -207,8 +207,7 @@ class UIManager final : public ShadowTreeDelegate {
|
||||
|
||||
void reportMount(SurfaceId surfaceId) const;
|
||||
|
||||
void updateShadowTree(
|
||||
const std::unordered_map<Tag, folly::dynamic>& tagToProps);
|
||||
void updateShadowTree(std::unordered_map<Tag, folly::dynamic>&& tagToProps);
|
||||
|
||||
#pragma mark - Add & Remove event listener
|
||||
|
||||
|
||||
+7
-6
@@ -86,10 +86,15 @@ void addAncestorsToUpdateList(
|
||||
* license).
|
||||
*/
|
||||
void UIManager::updateShadowTree(
|
||||
const std::unordered_map<Tag, folly::dynamic>& tagToProps) {
|
||||
std::unordered_map<Tag, folly::dynamic>&& tagToProps) {
|
||||
const auto& contextContainer = *contextContainer_;
|
||||
|
||||
std::unordered_map<Tag, folly::dynamic> remainingTagToProps = tagToProps;
|
||||
auto remainingTagToProps = std::move(tagToProps);
|
||||
|
||||
if (delegate_ != nullptr) {
|
||||
delegate_->uiManagerDidUpdateShadowTree(remainingTagToProps);
|
||||
}
|
||||
|
||||
getShadowTreeRegistry().enumerate([&](const ShadowTree& shadowTree,
|
||||
bool& stop) {
|
||||
if (remainingTagToProps.empty()) {
|
||||
@@ -219,10 +224,6 @@ void UIManager::updateShadowTree(
|
||||
LOG(ERROR) << "Root ShadowNode has not been cloned";
|
||||
}
|
||||
});
|
||||
|
||||
if (delegate_ != nullptr) {
|
||||
delegate_->uiManagerDidUpdateShadowTree(tagToProps);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace facebook::react
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ class MergedValueDispatcher {
|
||||
public:
|
||||
using DispatchFunction = std::function<void(std::function<void()>&&)>;
|
||||
using MergedValueFunction =
|
||||
std::function<void(std::unordered_map<Tag, folly::dynamic> tagToProps)>;
|
||||
std::function<void(std::unordered_map<Tag, folly::dynamic>&& tagToProps)>;
|
||||
|
||||
/**
|
||||
* Creates a MergedValueDispatcher with the given dispatch function.
|
||||
|
||||
+2
-3
@@ -49,9 +49,8 @@ NativeAnimatedNodesManagerProvider::getOrCreate(
|
||||
[jsInvoker](std::function<void()>&& func) {
|
||||
jsInvoker->invokeAsync(std::move(func));
|
||||
},
|
||||
[uiManager](
|
||||
const std::unordered_map<Tag, folly::dynamic>& tagToProps) {
|
||||
uiManager->updateShadowTree(tagToProps);
|
||||
[uiManager](std::unordered_map<Tag, folly::dynamic>&& tagToProps) {
|
||||
uiManager->updateShadowTree(std::move(tagToProps));
|
||||
});
|
||||
|
||||
fabricCommitCallback =
|
||||
|
||||
Reference in New Issue
Block a user