From 205c4b78f7c5d6e632386a7f5882238b3f474002 Mon Sep 17 00:00:00 2001 From: slaren Date: Wed, 7 Aug 2024 01:51:01 +0200 Subject: [PATCH] refactor --- examples/llama-bench/llama-bench.cpp | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/examples/llama-bench/llama-bench.cpp b/examples/llama-bench/llama-bench.cpp index e33d73e52..42918bfc7 100644 --- a/examples/llama-bench/llama-bench.cpp +++ b/examples/llama-bench/llama-bench.cpp @@ -116,26 +116,15 @@ static std::string get_cpu_info() { } char cpu_brand[256]; DWORD cpu_brand_size = sizeof(cpu_brand); - if (RegQueryValueEx(hKey, + if (RegQueryValueExA(hKey, TEXT("ProcessorNameString"), NULL, NULL, (LPBYTE)cpu_brand, - &cpu_brand_size) != ERROR_SUCCESS) { - RegCloseKey(hKey); - // fail to read processor information - return ""; + &cpu_brand_size) == ERROR_SUCCESS) { + id.assign(cpu_brand, cpu_brand_size); } RegCloseKey(hKey); - - // ensure the string is null-terminated - if (cpu_brand_size >= sizeof(cpu_brand)) { - cpu_brand[sizeof(cpu_brand) - 1] = '\0'; - } else { - cpu_brand[cpu_brand_size] = '\0'; - } - - id = std::string(cpu_brand); #endif // TODO: other platforms return id;