Skip to content

Commit 5ffff01

Browse files
mrousavymeta-codesync[bot]
authored andcommitted
perf: Move func into CallInvoker::invokeAsync (#54141)
Summary: Instead of copying the `std::function` into `invokeAsync`, we now move it. ## Changelog: [GENERAL] [CHANGED] - Move `std::function` into `CallInvoker::invokeAsync` instead of copying it <!-- Help reviewers and the release process by writing your own changelog entry. Pick one each for the category and type tags: [ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message For more details, see: https://reactnative.dev/contributing/changelogs-in-pull-requests Pull Request resolved: #54141 Test Plan: Build, run. A lot of code still uses the old `invokeAsync` function. Reviewed By: christophpurrer Differential Revision: D84563949 Pulled By: javache fbshipit-source-id: 283be3d12f1ac1c7f3da528c6b50b36cc81cd82a
1 parent 6d7a93f commit 5ffff01

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

  • packages/react-native/ReactCommon/callinvoker/ReactCommon

packages/react-native/ReactCommon/callinvoker/ReactCommon/CallInvoker.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ class CallInvoker {
3838

3939
// Backward compatibility only, prefer the CallFunc methods instead
4040
virtual void invokeAsync(std::function<void()>&& func) noexcept {
41-
invokeAsync([func](jsi::Runtime&) { func(); });
41+
invokeAsync([func = std::move(func)](jsi::Runtime&) { func(); });
4242
}
4343

4444
virtual void invokeSync(std::function<void()>&& func) {
45-
invokeSync([func](jsi::Runtime&) { func(); });
45+
invokeSync([func = std::move(func)](jsi::Runtime&) { func(); });
4646
}
4747

4848
virtual ~CallInvoker() = default;

0 commit comments

Comments
 (0)