diff --git a/src/lock/print.cpp b/src/lock/print.cpp index 7d32de2fec2..d9fba8eb6f7 100644 --- a/src/lock/print.cpp +++ b/src/lock/print.cpp @@ -851,7 +851,9 @@ int CLIB_ROUTINE main( int argc, char *argv[]) SLONG hash_max_count = 0; SLONG hash_min_count = 10000000; USHORT i = 0; - unsigned int distribution[21] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; + static const int MAX_MAX_COUNT_STATS = 21; + static const int LAST_MAX_COUNT_INDEX = MAX_MAX_COUNT_STATS - 1; + unsigned int distribution[MAX_MAX_COUNT_STATS] = {0}; // C++11 default brace initialization to zero for (const srq* slot = LOCK_header->lhb_hash; i < LOCK_header->lhb_hash_slots; slot++, i++) { SLONG hash_lock_count = 0; @@ -865,8 +867,8 @@ int CLIB_ROUTINE main( int argc, char *argv[]) hash_min_count = hash_lock_count; if (hash_lock_count > hash_max_count) hash_max_count = hash_lock_count; - if (hash_lock_count > 20) - hash_lock_count = 20; + if (hash_lock_count > LAST_MAX_COUNT_INDEX) + hash_lock_count = LAST_MAX_COUNT_INDEX; ++distribution[hash_lock_count]; } @@ -876,15 +878,16 @@ int CLIB_ROUTINE main( int argc, char *argv[]) hash_min_count, (hash_total_count / LOCK_header->lhb_hash_slots), hash_max_count); + // Hash distribution testing output. To be removed unless is considered useful for end users. FPRINTF(outfile, "\tHash lengths distribution:\n"); - if (hash_max_count >= 20) - hash_max_count = 19; + if (hash_max_count >= LAST_MAX_COUNT_INDEX) + hash_max_count = LAST_MAX_COUNT_INDEX - 1; for (int i = hash_min_count; i<=hash_max_count; ++i) { - FPRINTF(outfile, "\t\t%-2d : %8u\t(%d%%)\n", i, distribution[i], distribution[i]*100/LOCK_header->lhb_hash_slots); + FPRINTF(outfile, "\t\t%-2d : %8u\t(%d%%)\n", i, distribution[i], distribution[i] * 100 / LOCK_header->lhb_hash_slots); } - if (hash_max_count == 19) - FPRINTF(outfile, "\t\t> : %8u\t(%d%%)\n", distribution[20], distribution[20]*100/LOCK_header->lhb_hash_slots); + if (hash_max_count == LAST_MAX_COUNT_INDEX - 1) + FPRINTF(outfile, "\t\t> : %8u\t(%d%%)\n", distribution[LAST_MAX_COUNT_INDEX], distribution[LAST_MAX_COUNT_INDEX] * 100 / LOCK_header->lhb_hash_slots); const shb* a_shb = (shb*) SRQ_ABS_PTR(LOCK_header->lhb_secondary); FPRINTF(outfile,