aboutsummaryrefslogtreecommitdiff
path: root/c/debug.cpp
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2022-07-31 19:56:53 +0200
committerJohn Ankarström <john@ankarstrom.se>2022-07-31 19:58:54 +0200
commitd9e1caa37e53c7dbc42b1fc652efc23a40c47c42 (patch)
treed2a1608a3c88fef98af9a356a116af3551ea5680 /c/debug.cpp
parentd9bafcecfd60f38f98bca8a1705f6007b39e18a2 (diff)
downloadEpisodeBrowser-d9e1caa37e53c7dbc42b1fc652efc23a40c47c42.tar.gz
Limit use of Hungarian notation.
I don't hate Hungarian notation. It has some very nice qualities. But it also adds a lot of typing. That said, not using it feels a bit... unsafe. I might go back on this decision. We'll see.
Diffstat (limited to 'c/debug.cpp')
-rw-r--r--c/debug.cpp48
1 files changed, 24 insertions, 24 deletions
diff --git a/c/debug.cpp b/c/debug.cpp
index e22234a..07006a9 100644
--- a/c/debug.cpp
+++ b/c/debug.cpp
@@ -10,16 +10,16 @@ struct Avg {
long long sum;
};
-static long long llFrequency;
+static long long freq;
-Benchmark::Benchmark(const char* const szName, const int iId, const int iAvgMax)
- : id(iId), avgmax(iAvgMax), name(szName)
+Benchmark::Benchmark(const char* const name, const int id, const int avgmax)
+ : id(id), avgmax(avgmax), name(name)
{
- if (!llFrequency) {
- static LARGE_INTEGER liFrequency;
- if (!QueryPerformanceFrequency(&liFrequency))
+ if (!freq) {
+ static LARGE_INTEGER liFreq;
+ if (!QueryPerformanceFrequency(&liFreq))
throw Win32Error();
- llFrequency = liFrequency.QuadPart;
+ freq = liFreq.QuadPart;
}
LARGE_INTEGER liTicks;
@@ -42,32 +42,32 @@ Benchmark::~Benchmark()
if (!QueryPerformanceCounter(&liTicks))
return;
- long long ll = liTicks.QuadPart-ticks;
- ll *= 1'000'000;
- ll /= llFrequency;
+ long long dif = liTicks.QuadPart-ticks;
+ dif *= 1'000'000;
+ dif /= freq;
- static Avg aAvg[256] = {0};
- for (size_t i = 0; i < sizeof(aAvg)/sizeof(*aAvg); i++) {
- Avg& avg = aAvg[i];
+ static Avg avgs[256] = {0};
+ for (size_t i = 0; i < sizeof(avgs)/sizeof(*avgs); i++) {
+ Avg& avg = avgs[i];
if (avg.id == id || !avg.id) {
avg.id = id;
if (avg.count < avgmax) {
avg.count++;
- avg.sum += ll;
+ avg.sum += dif;
} else {
avg.count = 1;
- avg.sum = ll;
+ avg.sum = dif;
}
printf("%s: %lld (%lld)\n",
- name, ll, avg.sum/avg.count);
+ name, dif, avg.sum/avg.count);
break;
}
}
}
-const char* SzFromUmsg(const unsigned uMsg)
+const char* MsgName(const unsigned uMsg)
{
- static const unsigned aKeyMsg[] = {
+ static const unsigned vKey[] = {
0, 1, 2, 3, 5, 6, 7, 8, 10, 11, 12, 13, 14, 15, 16, 17, 18,
19, 20, 21, 22, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
35, 36, 38, 39, 40, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,
@@ -94,7 +94,7 @@ const char* SzFromUmsg(const unsigned uMsg)
911, 1024
};
- static const char* const aValueMsg[] = {
+ static const char* const vValue[] = {
"WM_NUL", "WM_CREATE", "WM_DESTROY", "WM_MOVE", "WM_SIZE",
"WM_ACTIVATE", "WM_SETFOCUS", "WM_KILLFOCUS", "WM_ENABLE",
"WM_SETREDRAW", "WM_SETTEXT", "WM_GETTEXT",
@@ -192,11 +192,11 @@ const char* SzFromUmsg(const unsigned uMsg)
"WM_CTLINIT", "WM_PENEVENT", "WM_PENWINLAST", "WM_USER"
};
- static const char* const szUnknown = "unknown message";
+ static const char* const unknown = "unknown message";
- for (size_t i = 0; i < sizeof(aKeyMsg)/sizeof(*aKeyMsg); i++)
- if (aKeyMsg[i] == uMsg) {
- return aValueMsg[i];
+ for (size_t i = 0; i < sizeof(vKey)/sizeof(*vKey); i++)
+ if (vKey[i] == uMsg) {
+ return vValue[i];
}
- return szUnknown;
+ return unknown;
}