Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 258f48f

Browse files
committed
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
1 parent 8cd61d2 commit 258f48f

File tree

8 files changed

+13
-13
lines changed

8 files changed

+13
-13
lines changed

contrib/hstore/hstore_gist.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ ghstore_picksplit(PG_FUNCTION_ARGS)
459459
if (ISALLTRUE(datum_l) || ISALLTRUE(_j))
460460
{
461461
if (!ISALLTRUE(datum_l))
462-
MemSet((void *) union_l, 0xff, siglen);
462+
memset((void *) union_l, 0xff, siglen);
463463
}
464464
else
465465
{
@@ -475,7 +475,7 @@ ghstore_picksplit(PG_FUNCTION_ARGS)
475475
if (ISALLTRUE(datum_r) || ISALLTRUE(_j))
476476
{
477477
if (!ISALLTRUE(datum_r))
478-
MemSet((void *) union_r, 0xff, siglen);
478+
memset((void *) union_r, 0xff, siglen);
479479
}
480480
else
481481
{

contrib/intarray/_intbig_gist.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ g_intbig_picksplit(PG_FUNCTION_ARGS)
420420
if (ISALLTRUE(datum_l) || ISALLTRUE(_j))
421421
{
422422
if (!ISALLTRUE(datum_l))
423-
MemSet((void *) union_l, 0xff, siglen);
423+
memset((void *) union_l, 0xff, siglen);
424424
}
425425
else
426426
{
@@ -436,7 +436,7 @@ g_intbig_picksplit(PG_FUNCTION_ARGS)
436436
if (ISALLTRUE(datum_r) || ISALLTRUE(_j))
437437
{
438438
if (!ISALLTRUE(datum_r))
439-
MemSet((void *) union_r, 0xff, siglen);
439+
memset((void *) union_r, 0xff, siglen);
440440
}
441441
else
442442
{

contrib/ltree/_ltree_gist.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ _ltree_picksplit(PG_FUNCTION_ARGS)
345345
if (LTG_ISALLTRUE(datum_l) || LTG_ISALLTRUE(_j))
346346
{
347347
if (!LTG_ISALLTRUE(datum_l))
348-
MemSet((void *) union_l, 0xff, siglen);
348+
memset((void *) union_l, 0xff, siglen);
349349
}
350350
else
351351
{
@@ -361,7 +361,7 @@ _ltree_picksplit(PG_FUNCTION_ARGS)
361361
if (LTG_ISALLTRUE(datum_r) || LTG_ISALLTRUE(_j))
362362
{
363363
if (!LTG_ISALLTRUE(datum_r))
364-
MemSet((void *) union_r, 0xff, siglen);
364+
memset((void *) union_r, 0xff, siglen);
365365
}
366366
else
367367
{

contrib/oid2name/oid2name.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ sql_exec(PGconn *conn, const char *todo, bool quiet)
424424
}
425425
fprintf(stdout, "\n");
426426
pad = (char *) pg_malloc(l + 1);
427-
MemSet(pad, '-', l);
427+
memset(pad, '-', l);
428428
pad[l] = '\0';
429429
fprintf(stdout, "%s\n", pad);
430430
free(pad);

contrib/pg_trgm/trgm_gist.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -914,7 +914,7 @@ gtrgm_picksplit(PG_FUNCTION_ARGS)
914914
if (ISALLTRUE(datum_l) || cache[j].allistrue)
915915
{
916916
if (!ISALLTRUE(datum_l))
917-
MemSet((void *) GETSIGN(datum_l), 0xff, siglen);
917+
memset((void *) GETSIGN(datum_l), 0xff, siglen);
918918
}
919919
else
920920
{
@@ -930,7 +930,7 @@ gtrgm_picksplit(PG_FUNCTION_ARGS)
930930
if (ISALLTRUE(datum_r) || cache[j].allistrue)
931931
{
932932
if (!ISALLTRUE(datum_r))
933-
MemSet((void *) GETSIGN(datum_r), 0xff, siglen);
933+
memset((void *) GETSIGN(datum_r), 0xff, siglen);
934934
}
935935
else
936936
{

src/backend/access/hash/hashovfl.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,7 @@ _hash_initbitmapbuffer(Buffer buf, uint16 bmsize, bool initpage)
760760

761761
/* set all of the bits to 1 */
762762
freep = HashPageGetBitmap(pg);
763-
MemSet(freep, 0xFF, bmsize);
763+
memset(freep, 0xFF, bmsize);
764764

765765
/*
766766
* Set pd_lower just past the end of the bitmap page data. We could even

src/backend/replication/walreceiver.c

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

src/backend/utils/adt/tsgistidx.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,7 @@ gtsvector_picksplit(PG_FUNCTION_ARGS)
753753
if (ISALLTRUE(datum_l) || cache[j].allistrue)
754754
{
755755
if (!ISALLTRUE(datum_l))
756-
MemSet((void *) GETSIGN(datum_l), 0xff, siglen);
756+
memset((void *) GETSIGN(datum_l), 0xff, siglen);
757757
}
758758
else
759759
{
@@ -769,7 +769,7 @@ gtsvector_picksplit(PG_FUNCTION_ARGS)
769769
if (ISALLTRUE(datum_r) || cache[j].allistrue)
770770
{
771771
if (!ISALLTRUE(datum_r))
772-
MemSet((void *) GETSIGN(datum_r), 0xff, siglen);
772+
memset((void *) GETSIGN(datum_r), 0xff, siglen);
773773
}
774774
else
775775
{

0 commit comments

Comments
 (0)