From a79d21c83e3fa433924999940c18e40fe980f50f Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Fri, 30 Jan 2015 16:56:49 -0200 Subject: Service: Clean-up Interface --- src/core/hle/service/service.h | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) (limited to 'src/core/hle/service/service.h') diff --git a/src/core/hle/service/service.h b/src/core/hle/service/service.h index 533d3565..121e6993 100644 --- a/src/core/hle/service/service.h +++ b/src/core/hle/service/service.h @@ -5,11 +5,12 @@ #pragma once #include -#include #include #include #include +#include + #include "common/common.h" #include "common/string_util.h" #include "core/mem_map.h" @@ -69,21 +70,6 @@ public: return "[UNKNOWN SERVICE PORT]"; } - /// Allocates a new handle for the service - Handle CreateHandle(Kernel::Object *obj) { - // TODO(yuriks): Fix error reporting - Handle handle = Kernel::g_handle_table.Create(obj).ValueOr(INVALID_HANDLE); - m_handles.push_back(handle); - return handle; - } - - /// Frees a handle from the service - template - void DeleteHandle(const Handle handle) { - Kernel::g_handle_table.Close(handle); - m_handles.erase(std::remove(m_handles.begin(), m_handles.end(), handle), m_handles.end()); - } - ResultVal SyncRequest() override { u32* cmd_buff = Kernel::GetCommandBuffer(); auto itr = m_functions.find(cmd_buff[0]); @@ -109,16 +95,17 @@ protected: /** * Registers the functions in the service */ - void Register(const FunctionInfo* functions, int len) { - for (int i = 0; i < len; i++) { - m_functions[functions[i].id] = functions[i]; + template + void Register(const FunctionInfo (&functions)[N]) { + m_functions.reserve(N); + for (auto& fn : functions) { + // Usually this array is sorted by id already, so hint to instead at the end + m_functions.emplace_hint(m_functions.cend(), fn.id, fn); } } private: - - std::vector m_handles; - std::map m_functions; + boost::container::flat_map m_functions; }; -- cgit v1.2.3