library: tweaked key used in hash table, <meminfo> api
This small change was a result of some experimentation trading our current 'hsearch' hash scheme for 'gperf'. I discovered that when the ':' character was a part of each 'gperf' key, that generated search logic was more complicated and thus slower. But without a ':', it was a little cleaner/leaner and therefore slightly faster. Assuming that the same trailing ':' *might* affect the current 'hsearch' logic, to be safe we will remove it. [ while the 'gperf' version will slightly outperform ] [ an 'hsearch', too many ugly implementation details ] [ were exposed which complicates future maintenance. ] [ thus, we'll retain our current 'hsearch' approach. ] Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
parent
f4e9195149
commit
add01998e4
@ -542,9 +542,9 @@ static inline int meminfo_items_check_failed (
|
||||
static int meminfo_make_hash_failed (
|
||||
struct meminfo_info *info)
|
||||
{
|
||||
#define htVAL(f) e.key = STRINGIFY(f) ":"; e.data = &info->hist.new. f; \
|
||||
#define htVAL(f) e.key = STRINGIFY(f); e.data = &info->hist.new. f; \
|
||||
if (!hsearch_r(e, ENTER, &ep, &info->hashtab)) return 1;
|
||||
#define htXTRA(k,f) e.key = STRINGIFY(k) ":"; e.data = &info->hist.new. f; \
|
||||
#define htXTRA(k,f) e.key = STRINGIFY(k); e.data = &info->hist.new. f; \
|
||||
if (!hsearch_r(e, ENTER, &ep, &info->hashtab)) return 1;
|
||||
ENTRY e, *ep;
|
||||
size_t n;
|
||||
@ -672,7 +672,7 @@ static int meminfo_read_failed (
|
||||
static ENTRY e; // just to keep coverity off our backs (e.data)
|
||||
ENTRY *ep;
|
||||
|
||||
if (!(tail = strchr(head, ' ')))
|
||||
if (!(tail = strchr(head, ':')))
|
||||
break;
|
||||
*tail = '\0';
|
||||
valptr = NULL;
|
||||
|
Loading…
Reference in New Issue
Block a user