diff --git a/ddprof-lib/src/main/cpp/arguments.cpp b/ddprof-lib/src/main/cpp/arguments.cpp index 52b55d78b..b08519990 100644 --- a/ddprof-lib/src/main/cpp/arguments.cpp +++ b/ddprof-lib/src/main/cpp/arguments.cpp @@ -42,21 +42,13 @@ static const Multiplier UNIVERSAL[] = { {'n', 1}, {'u', 1000}, {'m', 1000000}, {'s', 1000000000}, {'b', 1}, {'k', 1024}, {'g', 1073741824}, {0, 0}}; -// Statically compute hash code of a string containing up to 12 [a-z] letters -#define HASH(s) \ - ((s[0] & 31LL) | (s[1] & 31LL) << 5 | (s[2] & 31LL) << 10 | \ - (s[3] & 31LL) << 15 | (s[4] & 31LL) << 20 | (s[5] & 31LL) << 25 | \ - (s[6] & 31LL) << 30 | (s[7] & 31LL) << 35 | (s[8] & 31LL) << 40 | \ - (s[9] & 31LL) << 45 | (s[10] & 31LL) << 50 | (s[11] & 31LL) << 55) - // Simulate switch statement over string hashes #define SWITCH(arg) \ - long long arg_hash = hash(arg); \ if (0) #define CASE(s) \ } \ - else if (arg_hash == HASH(s " ")) { + else if (strcasecmp(arg, s) == 0) { #define DEFAULT() \ } \ @@ -437,15 +429,6 @@ const char *Arguments::file() { return _file; } -// Should match statically computed HASH(arg) -long long Arguments::hash(const char *arg) { - long long h = 0; - for (int shift = 0; *arg != 0; shift += 5) { - h |= (*arg++ & 31LL) << shift; - } - return h; -} - // Expands the following patterns: // %p process id // %t timestamp (yyyyMMdd-hhmmss) diff --git a/ddprof-lib/src/main/cpp/arguments.h b/ddprof-lib/src/main/cpp/arguments.h index 2fa52360e..b97c352ae 100644 --- a/ddprof-lib/src/main/cpp/arguments.h +++ b/ddprof-lib/src/main/cpp/arguments.h @@ -152,7 +152,6 @@ class Arguments { bool _shared; bool _persistent; const char *expandFilePattern(const char *pattern); - static long long hash(const char *arg); static long parseUnits(const char *str, const Multiplier *multipliers); static bool isCpuEvent(const char *event) { // event == NULL will default to EVENT_CPU