diff options
author | Yuri Kunde Schlesner <yuriks@yuriks.net> | 2015-01-30 19:56:49 +0100 |
---|---|---|
committer | Yuri Kunde Schlesner <yuriks@yuriks.net> | 2015-02-02 18:36:59 +0100 |
commit | a79d21c83e3fa433924999940c18e40fe980f50f (patch) | |
tree | 938ffa50ced999b31f0ae7194fd7e21126c082b6 /src/core/hle/service/service.h | |
parent | Make Port/Service registration and querying more HW-accurate (diff) | |
download | yuzu-a79d21c83e3fa433924999940c18e40fe980f50f.tar yuzu-a79d21c83e3fa433924999940c18e40fe980f50f.tar.gz yuzu-a79d21c83e3fa433924999940c18e40fe980f50f.tar.bz2 yuzu-a79d21c83e3fa433924999940c18e40fe980f50f.tar.lz yuzu-a79d21c83e3fa433924999940c18e40fe980f50f.tar.xz yuzu-a79d21c83e3fa433924999940c18e40fe980f50f.tar.zst yuzu-a79d21c83e3fa433924999940c18e40fe980f50f.zip |
Diffstat (limited to 'src/core/hle/service/service.h')
-rw-r--r-- | src/core/hle/service/service.h | 31 |
1 files changed, 9 insertions, 22 deletions
diff --git a/src/core/hle/service/service.h b/src/core/hle/service/service.h index 533d3565b..121e69932 100644 --- a/src/core/hle/service/service.h +++ b/src/core/hle/service/service.h @@ -5,11 +5,12 @@ #pragma once #include <algorithm> -#include <map> #include <string> #include <unordered_map> #include <vector> +#include <boost/container/flat_map.hpp> + #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 <class T> - 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<bool> 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 <size_t N> + 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<Handle> m_handles; - std::map<u32, FunctionInfo> m_functions; + boost::container::flat_map<u32, FunctionInfo> m_functions; }; |