library: improve code employing the search.h functions

When building the hash tables, a careless macro forced
a repetitive loading of a constant return value before
branching to the routine's actual return instructions.

This patch will avoid the overhead via a goto instead.

Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
Jim Warner 2024-07-24 00:00:00 -05:00 committed by Craig Small
parent 5c7a323fcb
commit 393985863e
2 changed files with 7 additions and 3 deletions

View File

@ -564,9 +564,9 @@ static int meminfo_make_hash_failed (
struct meminfo_info *info)
{
#define htVAL(f) e.key = STRINGIFY(f); e.data = &info->hist.new. f; \
if (!hsearch_r(e, ENTER, &ep, &info->hashtab)) return 1;
if (!hsearch_r(e, ENTER, &ep, &info->hashtab)) goto err_return;
#define htXTRA(k,f) e.key = STRINGIFY(k); e.data = &info->hist.new. f; \
if (!hsearch_r(e, ENTER, &ep, &info->hashtab)) return 1;
if (!hsearch_r(e, ENTER, &ep, &info->hashtab)) goto err_return;
ENTRY e, *ep;
size_t n;
@ -642,6 +642,8 @@ static int meminfo_make_hash_failed (
htVAL(Zswapped)
return 0;
err_return:
return 1;
#undef htVAL
#undef htXTRA
} // end: meminfo_make_hash_failed

View File

@ -985,7 +985,7 @@ static int vmstat_make_hash_failed (
struct vmstat_info *info)
{
#define htVAL(f) e.key = STRINGIFY(f); e.data = &info->hist.new. f; \
if (!hsearch_r(e, ENTER, &ep, &info->hashtab)) return 1;
if (!hsearch_r(e, ENTER, &ep, &info->hashtab)) goto err_return;
ENTRY e, *ep;
size_t n;
@ -1147,6 +1147,8 @@ static int vmstat_make_hash_failed (
htVAL(zone_reclaim_failed)
return 0;
err_return:
return 1;
#undef htVAL
} // end: vmstat_make_hash_failed