Skip to content

Commit f14a4d1

Browse files
committed
Use std::mutex instead of never-shared std::shared_mutex in ShadowNodeFamily
ShadowNodeFamily::mutex_ is declared std::shared_mutex but has not been acquired in shared mode since February 2020. All three call sites take it exclusively via unique_lock, and there is no shared_lock in the class. Of the 17 classes in ReactCommon that declare a std::shared_mutex, this is the only one that never takes a shared_lock. Reduces sizeof(ShadowNodeFamily) from 384 to 272 bytes on arm64 (-112, -29%). There is one family per host element, so this scales with tree size. Changelog: [GENERAL] [CHANGED] - Replace never-shared std::shared_mutex with std::mutex in ShadowNodeFamily
1 parent 4be68ef commit f14a4d1

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

packages/react-native/ReactCommon/react/renderer/core/ShadowNodeFamily.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
#include <memory>
1111
#include <mutex>
12-
#include <shared_mutex>
1312

1413
#include <react/renderer/core/EventEmitter.h>
1514
#include <react/renderer/core/InstanceHandle.h>
@@ -145,7 +144,7 @@ class ShadowNodeFamily final : public jsi::NativeState {
145144

146145
EventDispatcher::Weak eventDispatcher_;
147146
std::shared_ptr<const State> mostRecentState_;
148-
mutable std::shared_mutex mutex_;
147+
mutable std::mutex mutex_;
149148

150149
std::function<void(ShadowNodeFamily &family)> onUnmountedFamilyDestroyedCallback_ = nullptr;
151150

0 commit comments

Comments
 (0)