aboutsummaryrefslogtreecommitdiff
path: root/src/video_core/regs.cpp
diff options
context:
space:
mode:
authorYuri Kunde Schlesner <yuriks@yuriks.net>2017-02-12 12:33:26 -0800
committerGitHub <noreply@github.com>2017-02-12 12:33:26 -0800
commit84f423dea686f1edb08a23d2e2dbc59146f34e4d (patch)
tree5a83052ad2f5888a282d4db2ef9b9f2d4e647a60 /src/video_core/regs.cpp
parent21a48770b8c68b9868b83388e745ab1c44561667 (diff)
parent176b247d6873efb5e00211801618c2bd63dcfa4f (diff)
Merge pull request #2550 from yuriks/pica-refactor2
Small VideoCore cleanups
Diffstat (limited to 'src/video_core/regs.cpp')
-rw-r--r--src/video_core/regs.cpp21
1 files changed, 8 insertions, 13 deletions
diff --git a/src/video_core/regs.cpp b/src/video_core/regs.cpp
index f47e9e7634..2699e710aa 100644
--- a/src/video_core/regs.cpp
+++ b/src/video_core/regs.cpp
@@ -2,8 +2,8 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
+#include <algorithm>
#include <iterator>
-#include <unordered_map>
#include <utility>
#include "common/common_types.h"
@@ -474,19 +474,14 @@ static const std::pair<u16, const char*> register_names[] = {
{0x2DD, "GPUREG_VSH_OPDESCS_DATA7"},
};
-std::string Regs::GetCommandName(int index) {
- static std::unordered_map<u32, const char*> map;
-
- if (map.empty()) {
- map.insert(std::begin(register_names), std::end(register_names));
- }
-
- // Return empty string if no match is found
- auto it = map.find(index);
- if (it != map.end()) {
- return it->second;
+const char* Regs::GetRegisterName(u16 index) {
+ auto found = std::lower_bound(std::begin(register_names), std::end(register_names), index,
+ [](auto p, auto i) { return p.first < i; });
+ if (found->first == index) {
+ return found->second;
} else {
- return std::string();
+ // Return empty string if no match is found
+ return "";
}
}