From afccc35e7980e7f2dababe48b9f0d2f4196cb6b7 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Thu, 7 Oct 2021 19:14:31 -0700 Subject: [PATCH] erpt: save 8KB --- .../source/erpt/srv/erpt_srv_keys.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/libraries/libstratosphere/source/erpt/srv/erpt_srv_keys.cpp b/libraries/libstratosphere/source/erpt/srv/erpt_srv_keys.cpp index ee0b72264..49fc15f35 100644 --- a/libraries/libstratosphere/source/erpt/srv/erpt_srv_keys.cpp +++ b/libraries/libstratosphere/source/erpt/srv/erpt_srv_keys.cpp @@ -73,7 +73,19 @@ namespace ams::erpt::srv { } bool IsProductionMode() { - static bool s_is_prod_mode = IsProductionModeImpl(); + static constinit bool s_initialized = false; + static constinit bool s_is_prod_mode = true; + static constinit os::SdkMutex s_mutex; + + if (AMS_UNLIKELY(!s_initialized)) { + std::scoped_lock lk(s_mutex); + + if (AMS_LIKELY(!s_initialized)) { + s_is_prod_mode = IsProductionModeImpl(); + s_initialized = true; + } + } + return s_is_prod_mode; }