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
pull/92/head
Peter Eisentraut 3 years ago
parent 8cd61d288a
commit 258f48f858
  1. 4
      contrib/hstore/hstore_gist.c
  2. 4
      contrib/intarray/_intbig_gist.c
  3. 4
      contrib/ltree/_ltree_gist.c
  4. 2
      contrib/oid2name/oid2name.c
  5. 4
      contrib/pg_trgm/trgm_gist.c
  6. 2
      src/backend/access/hash/hashovfl.c
  7. 2
      src/backend/replication/walreceiver.c
  8. 4
      src/backend/utils/adt/tsgistidx.c

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

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

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

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

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

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

@ -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 * see details. Other users only get the pid value to know whether it
* is a WAL receiver, but no details. * 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 else
{ {

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

Loading…
Cancel
Save