Change some unnecessary MemSet calls

MemSet() with a value other than 0 just falls back to memset(), so the
indirection is unnecessary if the value is constant and not 0.  Since
there is some interest in getting rid of MemSet(), this gets some easy
cases out of the way.  (There are a few MemSet() calls that I didn't
change to maintain the consistency with their surrounding code.)

Discussion: https://www.postgresql.org/message-id/flat/CAEudQApCeq4JjW1BdnwU=m=-DvG5WyUik0Yfn3p6UNphiHjj+w@mail.gmail.com
This commit is contained in:
Peter Eisentraut 2022-07-01 00:16:38 +02:00
parent 8cd61d288a
commit 258f48f858
8 changed files with 13 additions and 13 deletions

View File

@ -459,7 +459,7 @@ ghstore_picksplit(PG_FUNCTION_ARGS)
if (ISALLTRUE(datum_l) || ISALLTRUE(_j))
{
if (!ISALLTRUE(datum_l))
MemSet((void *) union_l, 0xff, siglen);
memset((void *) union_l, 0xff, siglen);
}
else
{
@ -475,7 +475,7 @@ ghstore_picksplit(PG_FUNCTION_ARGS)
if (ISALLTRUE(datum_r) || ISALLTRUE(_j))
{
if (!ISALLTRUE(datum_r))
MemSet((void *) union_r, 0xff, siglen);
memset((void *) union_r, 0xff, siglen);
}
else
{

View File

@ -420,7 +420,7 @@ g_intbig_picksplit(PG_FUNCTION_ARGS)
if (ISALLTRUE(datum_l) || ISALLTRUE(_j))
{
if (!ISALLTRUE(datum_l))
MemSet((void *) union_l, 0xff, siglen);
memset((void *) union_l, 0xff, siglen);
}
else
{
@ -436,7 +436,7 @@ g_intbig_picksplit(PG_FUNCTION_ARGS)
if (ISALLTRUE(datum_r) || ISALLTRUE(_j))
{
if (!ISALLTRUE(datum_r))
MemSet((void *) union_r, 0xff, siglen);
memset((void *) union_r, 0xff, siglen);
}
else
{

View File

@ -345,7 +345,7 @@ _ltree_picksplit(PG_FUNCTION_ARGS)
if (LTG_ISALLTRUE(datum_l) || LTG_ISALLTRUE(_j))
{
if (!LTG_ISALLTRUE(datum_l))
MemSet((void *) union_l, 0xff, siglen);
memset((void *) union_l, 0xff, siglen);
}
else
{
@ -361,7 +361,7 @@ _ltree_picksplit(PG_FUNCTION_ARGS)
if (LTG_ISALLTRUE(datum_r) || LTG_ISALLTRUE(_j))
{
if (!LTG_ISALLTRUE(datum_r))
MemSet((void *) union_r, 0xff, siglen);
memset((void *) union_r, 0xff, siglen);
}
else
{

View File

@ -424,7 +424,7 @@ sql_exec(PGconn *conn, const char *todo, bool quiet)
}
fprintf(stdout, "\n");
pad = (char *) pg_malloc(l + 1);
MemSet(pad, '-', l);
memset(pad, '-', l);
pad[l] = '\0';
fprintf(stdout, "%s\n", pad);
free(pad);

View File

@ -914,7 +914,7 @@ gtrgm_picksplit(PG_FUNCTION_ARGS)
if (ISALLTRUE(datum_l) || cache[j].allistrue)
{
if (!ISALLTRUE(datum_l))
MemSet((void *) GETSIGN(datum_l), 0xff, siglen);
memset((void *) GETSIGN(datum_l), 0xff, siglen);
}
else
{
@ -930,7 +930,7 @@ gtrgm_picksplit(PG_FUNCTION_ARGS)
if (ISALLTRUE(datum_r) || cache[j].allistrue)
{
if (!ISALLTRUE(datum_r))
MemSet((void *) GETSIGN(datum_r), 0xff, siglen);
memset((void *) GETSIGN(datum_r), 0xff, siglen);
}
else
{

View File

@ -760,7 +760,7 @@ _hash_initbitmapbuffer(Buffer buf, uint16 bmsize, bool initpage)
/* set all of the bits to 1 */
freep = HashPageGetBitmap(pg);
MemSet(freep, 0xFF, bmsize);
memset(freep, 0xFF, bmsize);
/*
* Set pd_lower just past the end of the bitmap page data. We could even

View File

@ -1410,7 +1410,7 @@ pg_stat_get_wal_receiver(PG_FUNCTION_ARGS)
* see details. Other users only get the pid value to know whether it
* is a WAL receiver, but no details.
*/
MemSet(&nulls[1], true, sizeof(bool) * (tupdesc->natts - 1));
memset(&nulls[1], true, sizeof(bool) * (tupdesc->natts - 1));
}
else
{

View File

@ -753,7 +753,7 @@ gtsvector_picksplit(PG_FUNCTION_ARGS)
if (ISALLTRUE(datum_l) || cache[j].allistrue)
{
if (!ISALLTRUE(datum_l))
MemSet((void *) GETSIGN(datum_l), 0xff, siglen);
memset((void *) GETSIGN(datum_l), 0xff, siglen);
}
else
{
@ -769,7 +769,7 @@ gtsvector_picksplit(PG_FUNCTION_ARGS)
if (ISALLTRUE(datum_r) || cache[j].allistrue)
{
if (!ISALLTRUE(datum_r))
MemSet((void *) GETSIGN(datum_r), 0xff, siglen);
memset((void *) GETSIGN(datum_r), 0xff, siglen);
}
else
{