From 6ff0bf3101ef4df37d54f0554febeb33fdc97807 Mon Sep 17 00:00:00 2001 From: Christoph Purrer Date: Mon, 6 Jan 2025 12:22:37 -0800 Subject: [PATCH] Make SurfaceManager const correct (#48485) Summary: [Changelog] [Internal] - Make SurfaceManager const correct This marks methods which don't modify member props as `const` and others as non `const`. The current API signature is misleading as `const` methods do alter `mutable` members Reviewed By: rshest Differential Revision: D67820439 --- .../react/renderer/scheduler/SurfaceManager.cpp | 6 +++--- .../ReactCommon/react/renderer/scheduler/SurfaceManager.h | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/react-native/ReactCommon/react/renderer/scheduler/SurfaceManager.cpp b/packages/react-native/ReactCommon/react/renderer/scheduler/SurfaceManager.cpp index f402420aac77..811c8c892818 100644 --- a/packages/react-native/ReactCommon/react/renderer/scheduler/SurfaceManager.cpp +++ b/packages/react-native/ReactCommon/react/renderer/scheduler/SurfaceManager.cpp @@ -26,7 +26,7 @@ void SurfaceManager::startSurface( const std::string& moduleName, const folly::dynamic& props, const LayoutConstraints& layoutConstraints, - const LayoutContext& layoutContext) const noexcept { + const LayoutContext& layoutContext) noexcept { { std::unique_lock lock(mutex_); auto surfaceHandler = SurfaceHandler{moduleName, surfaceId}; @@ -44,7 +44,7 @@ void SurfaceManager::startSurface( }); } -void SurfaceManager::stopSurface(SurfaceId surfaceId) const noexcept { +void SurfaceManager::stopSurface(SurfaceId surfaceId) noexcept { visit(surfaceId, [&](const SurfaceHandler& surfaceHandler) { surfaceHandler.stop(); scheduler_.unregisterSurface(surfaceHandler); @@ -58,7 +58,7 @@ void SurfaceManager::stopSurface(SurfaceId surfaceId) const noexcept { } } -void SurfaceManager::stopAllSurfaces() const noexcept { +void SurfaceManager::stopAllSurfaces() noexcept { std::unordered_set surfaceIds; { std::shared_lock lock(mutex_); diff --git a/packages/react-native/ReactCommon/react/renderer/scheduler/SurfaceManager.h b/packages/react-native/ReactCommon/react/renderer/scheduler/SurfaceManager.h index 3b3d47ec8bee..d377a2a9903c 100644 --- a/packages/react-native/ReactCommon/react/renderer/scheduler/SurfaceManager.h +++ b/packages/react-native/ReactCommon/react/renderer/scheduler/SurfaceManager.h @@ -36,11 +36,11 @@ class SurfaceManager final { const std::string& moduleName, const folly::dynamic& props, const LayoutConstraints& layoutConstraints = {}, - const LayoutContext& layoutContext = {}) const noexcept; + const LayoutContext& layoutContext = {}) noexcept; - void stopSurface(SurfaceId surfaceId) const noexcept; + void stopSurface(SurfaceId surfaceId) noexcept; - void stopAllSurfaces() const noexcept; + void stopAllSurfaces() noexcept; Size measureSurface( SurfaceId surfaceId, @@ -63,7 +63,7 @@ class SurfaceManager final { const Scheduler& scheduler_; mutable std::shared_mutex mutex_; // Protects `registry_`. - mutable std::unordered_map registry_{}; + std::unordered_map registry_{}; }; } // namespace facebook::react