From 1a2efd130f3953758e9617c878d6daebe2492c56 Mon Sep 17 00:00:00 2001 From: lizzie Date: Wed, 4 Mar 2026 06:17:16 +0000 Subject: [PATCH] [hle] use ankerl:: for map, use const char* instead of std::string{} Signed-off-by: lizzie --- src/core/hle/service/service.cpp | 14 ++++++++------ src/core/hle/service/service.h | 26 ++++++++++---------------- 2 files changed, 18 insertions(+), 22 deletions(-) diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp index b972b83e1a..5572622f02 100644 --- a/src/core/hle/service/service.cpp +++ b/src/core/hle/service/service.cpp @@ -29,10 +29,13 @@ namespace Service { return function_string; } -ServiceFrameworkBase::ServiceFrameworkBase(Core::System& system_, const char* service_name_, - u32 max_sessions_, InvokerFn* handler_invoker_) - : SessionRequestHandler(system_.Kernel(), service_name_), system{system_}, - service_name{service_name_}, handler_invoker{handler_invoker_}, max_sessions{max_sessions_} {} +ServiceFrameworkBase::ServiceFrameworkBase(Core::System& system_, const char* service_name_, u32 max_sessions_, InvokerFn* handler_invoker_) + : SessionRequestHandler(system_.Kernel(), service_name_) + , system{system_} + , service_name{service_name_} + , handler_invoker{handler_invoker_} + , max_sessions{max_sessions_} +{} ServiceFrameworkBase::~ServiceFrameworkBase() { // Wait for other threads to release access before destroying @@ -50,8 +53,7 @@ void ServiceFrameworkBase::RegisterHandlersBaseTipc(const FunctionInfoBase* func // Usually this array is sorted by id already, so hint to insert at the end handlers_tipc.reserve(handlers_tipc.size() + n); for (std::size_t i = 0; i < n; ++i) - handlers_tipc.emplace_hint(handlers_tipc.cend(), functions[i].expected_header, - functions[i]); + handlers_tipc.emplace_hint(handlers_tipc.cend(), functions[i].expected_header, functions[i]); } void ServiceFrameworkBase::ReportUnimplementedFunction(HLERequestContext& ctx, diff --git a/src/core/hle/service/service.h b/src/core/hle/service/service.h index dbc870a662..99bdb0e6a1 100644 --- a/src/core/hle/service/service.h +++ b/src/core/hle/service/service.h @@ -8,8 +8,7 @@ #include #include -#include -#include +#include #include "common/common_types.h" #include "core/hle/service/hle_ipc.h" @@ -78,13 +77,6 @@ protected: [[nodiscard]] virtual std::unique_lock LockService() noexcept { return std::unique_lock{lock_service}; } - - /// System context that the service operates under. - Core::System& system; - - /// Identifier string used to connect to the service. - std::string service_name; - private: template friend class ServiceFramework; @@ -106,16 +98,19 @@ private: void RegisterHandlersBaseTipc(const FunctionInfoBase* functions, std::size_t n); void ReportUnimplementedFunction(HLERequestContext& ctx, const FunctionInfoBase* info); - boost::container::flat_map handlers; - boost::container::flat_map handlers_tipc; +protected: + ankerl::unordered_dense::map handlers; + ankerl::unordered_dense::map handlers_tipc; /// Used to gain exclusive access to the service members, e.g. from CoreTiming thread. std::mutex lock_service; + /// System context that the service operates under. + Core::System& system; + /// Identifier string used to connect to the service. + const char* service_name; /// Function used to safely up-cast pointers to the derived class before invoking a handler. InvokerFn* handler_invoker; - /// Maximum number of concurrent sessions that this service can handle. u32 max_sessions; - /// Flag to store if a port was already create/installed to detect multiple install attempts, /// which is not supported. bool service_registered = false; @@ -159,8 +154,7 @@ protected: * @param max_sessions_ Maximum number of sessions that can be connected to this service at the * same time. */ - explicit ServiceFramework(Core::System& system_, const char* service_name_, - u32 max_sessions_ = ServerSessionCountMax) + explicit ServiceFramework(Core::System& system_, const char* service_name_, u32 max_sessions_ = ServerSessionCountMax) : ServiceFrameworkBase(system_, service_name_, max_sessions_, Invoker) {} /// Registers handlers in the service. @@ -219,7 +213,7 @@ private: static void Invoker(ServiceFrameworkBase* object, HandlerFnP member, HLERequestContext& ctx) { // Cast back up to our original types and call the member function - (static_cast(object)->*static_cast>(member))(ctx); + (static_cast(object)->*HandlerFnP(member))(ctx); } };