diff options
-rw-r--r-- | xmrstak/backend/iBackend.hpp | 27 | ||||
-rw-r--r-- | xmrstak/misc/executor.cpp | 5 |
2 files changed, 23 insertions, 9 deletions
diff --git a/xmrstak/backend/iBackend.hpp b/xmrstak/backend/iBackend.hpp index dbfbc99..3d2115a 100644 --- a/xmrstak/backend/iBackend.hpp +++ b/xmrstak/backend/iBackend.hpp @@ -8,22 +8,33 @@ #include <vector> #include <string> +template <typename T, std::size_t N> +constexpr std::size_t countof(T const (&)[N]) noexcept +{ + return N; +} + namespace xmrstak { struct iBackend { - enum BackendType : uint32_t { UNKNOWN = 0, CPU = 1u, AMD = 2u, NVIDIA = 3u }; + enum BackendType : uint32_t { UNKNOWN = 0u, CPU = 1u, AMD = 2u, NVIDIA = 3u }; - static std::string getName(const BackendType type) + static const char* getName(const BackendType type) { - std::vector<std::string> backendNames = { - "UNKNOWN", - "CPU", - "AMD", - "NVIDIA" + const char* backendNames[] = { + "unknown", + "cpu", + "amd", + "nvidia" }; - return backendNames[static_cast<uint32_t>(type)]; + + uint32_t i = static_cast<uint32_t>(type); + if(i >= countof(backendNames)) + i = 0; + + return backendNames[i]; } std::atomic<uint64_t> iHashCount; diff --git a/xmrstak/misc/executor.cpp b/xmrstak/misc/executor.cpp index 454d1cf..07ab759 100644 --- a/xmrstak/misc/executor.cpp +++ b/xmrstak/misc/executor.cpp @@ -641,7 +641,10 @@ void executor::hashrate_report(std::string& out) size_t i; auto bType = static_cast<xmrstak::iBackend::BackendType>(b); - out.append("HASHRATE REPORT - ").append(xmrstak::iBackend::getName(bType)).append("\n"); + std::string name(xmrstak::iBackend::getName(bType)); + std::transform(name.begin(), name.end(), name.begin(), ::toupper); + + out.append("HASHRATE REPORT - ").append(name).append("\n"); out.append("| ID | 10s | 60s | 15m |"); if(nthd != 1) out.append(" ID | 10s | 60s | 15m |\n"); |