Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite8d5929

Browse files
Use pg_memory_is_all_zeros() in pgstatfuncs.c.
There are a few places in this file that use memset() and memcmp()to determine whether a section of memory is all zeros. This commitmodifies them to use pg_memory_is_all_zeros() instead. Thesearen't expected to be hot code paths, but this may optimize them abit. Plus, this allows us to remove some variables that were onlyneeded for the memset() and memcmp().Author: Bertrand DrouvotReviewed-by: Michael PaquierDiscussion:https://postgr.es/m/Z1hNubHfvMxlW6eu%40ip-10-97-1-34.eu-west-3.compute.internal
1 parent398d3e3 commite8d5929

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

‎src/backend/utils/adt/pgstatfuncs.c

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,6 @@ pg_stat_get_activity(PG_FUNCTION_ARGS)
361361
/* Values only available to role member or pg_read_all_stats */
362362
if (HAS_PGSTAT_PERMISSIONS(beentry->st_userid))
363363
{
364-
SockAddrzero_clientaddr;
365364
char*clipped_activity;
366365

367366
switch (beentry->st_state)
@@ -483,9 +482,8 @@ pg_stat_get_activity(PG_FUNCTION_ARGS)
483482
nulls[11]= true;
484483

485484
/* A zeroed client addr means we don't know */
486-
memset(&zero_clientaddr,0,sizeof(zero_clientaddr));
487-
if (memcmp(&(beentry->st_clientaddr),&zero_clientaddr,
488-
sizeof(zero_clientaddr))==0)
485+
if (pg_memory_is_all_zeros(&beentry->st_clientaddr,
486+
sizeof(beentry->st_clientaddr)))
489487
{
490488
nulls[12]= true;
491489
nulls[13]= true;
@@ -880,7 +878,6 @@ pg_stat_get_backend_client_addr(PG_FUNCTION_ARGS)
880878
{
881879
int32procNumber=PG_GETARG_INT32(0);
882880
PgBackendStatus*beentry;
883-
SockAddrzero_clientaddr;
884881
charremote_host[NI_MAXHOST];
885882
intret;
886883

@@ -891,9 +888,8 @@ pg_stat_get_backend_client_addr(PG_FUNCTION_ARGS)
891888
PG_RETURN_NULL();
892889

893890
/* A zeroed client addr means we don't know */
894-
memset(&zero_clientaddr,0,sizeof(zero_clientaddr));
895-
if (memcmp(&(beentry->st_clientaddr),&zero_clientaddr,
896-
sizeof(zero_clientaddr))==0)
891+
if (pg_memory_is_all_zeros(&beentry->st_clientaddr,
892+
sizeof(beentry->st_clientaddr)))
897893
PG_RETURN_NULL();
898894

899895
switch (beentry->st_clientaddr.addr.ss_family)
@@ -925,7 +921,6 @@ pg_stat_get_backend_client_port(PG_FUNCTION_ARGS)
925921
{
926922
int32procNumber=PG_GETARG_INT32(0);
927923
PgBackendStatus*beentry;
928-
SockAddrzero_clientaddr;
929924
charremote_port[NI_MAXSERV];
930925
intret;
931926

@@ -936,9 +931,8 @@ pg_stat_get_backend_client_port(PG_FUNCTION_ARGS)
936931
PG_RETURN_NULL();
937932

938933
/* A zeroed client addr means we don't know */
939-
memset(&zero_clientaddr,0,sizeof(zero_clientaddr));
940-
if (memcmp(&(beentry->st_clientaddr),&zero_clientaddr,
941-
sizeof(zero_clientaddr))==0)
934+
if (pg_memory_is_all_zeros(&beentry->st_clientaddr,
935+
sizeof(beentry->st_clientaddr)))
942936
PG_RETURN_NULL();
943937

944938
switch (beentry->st_clientaddr.addr.ss_family)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp