summaryrefslogtreecommitdiffstats
path: root/src/video_core
diff options
context:
space:
mode:
authorYuri Kunde Schlesner <yuriks@yuriks.net>2017-01-28 23:48:13 +0100
committerYuri Kunde Schlesner <yuriks@yuriks.net>2017-02-09 09:04:24 +0100
commitf241bb72f5b6b0b213053e000051bf3b7e6b4bb0 (patch)
tree8e5b02afe942842d4e86b420dfc4474224bbe114 /src/video_core
parentVideoCore: Use union to index into Regs struct (diff)
downloadyuzu-f241bb72f5b6b0b213053e000051bf3b7e6b4bb0.tar
yuzu-f241bb72f5b6b0b213053e000051bf3b7e6b4bb0.tar.gz
yuzu-f241bb72f5b6b0b213053e000051bf3b7e6b4bb0.tar.bz2
yuzu-f241bb72f5b6b0b213053e000051bf3b7e6b4bb0.tar.lz
yuzu-f241bb72f5b6b0b213053e000051bf3b7e6b4bb0.tar.xz
yuzu-f241bb72f5b6b0b213053e000051bf3b7e6b4bb0.tar.zst
yuzu-f241bb72f5b6b0b213053e000051bf3b7e6b4bb0.zip
Diffstat (limited to 'src/video_core')
-rw-r--r--src/video_core/regs.cpp21
-rw-r--r--src/video_core/regs.h4
2 files changed, 10 insertions, 15 deletions
diff --git a/src/video_core/regs.cpp b/src/video_core/regs.cpp
index f47e9e763..2699e710a 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 "";
}
}
diff --git a/src/video_core/regs.h b/src/video_core/regs.h
index e38ab4333..86826088b 100644
--- a/src/video_core/regs.h
+++ b/src/video_core/regs.h
@@ -64,8 +64,8 @@ struct Regs {
std::array<u32, NUM_REGS> reg_array;
};
- // Map register indices to names readable by humans
- static std::string GetCommandName(int index);
+ /// Map register indices to names readable by humans
+ static const char* GetRegisterName(u16 index);
};
static_assert(sizeof(Regs) == Regs::NUM_REGS * sizeof(u32), "Regs struct has wrong size");