mirror of
https://gitlab.com/procps-ng/procps.git
synced 2024-11-27 03:54:06 +08:00
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:
parent
5c7a323fcb
commit
393985863e
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user