]> granicus.if.org Git - postgresql/commitdiff
Use MemSet() rather than a loop to do blank-padding on PS_USE_CLOBBER_ARGV
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 21 Dec 2001 15:22:09 +0000 (15:22 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 21 Dec 2001 15:22:09 +0000 (15:22 +0000)
machines.  I have just been observing some scenarios where set_ps_display
accounts for more than 10% of the backend CPU, and this loop has to be
the reason.

src/backend/utils/misc/ps_status.c

index c2f1b8975db268169633f58a8a53647a08267bdc..c6e335561f14f0d1d9289ba49188fd9d8ac74fc8 100644 (file)
@@ -5,7 +5,7 @@
  * to contain some useful information. Mechanism differs wildly across
  * platforms.
  *
- * $Header: /cvsroot/pgsql/src/backend/utils/misc/ps_status.c,v 1.11 2001/11/06 01:15:29 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/misc/ps_status.c,v 1.12 2001/12/21 15:22:09 tgl Exp $
  *
  * Copyright 2000 by PostgreSQL Global Development Group
  * various details abducted from various places
@@ -265,13 +265,11 @@ set_ps_display(const char *activity)
 
 #ifdef PS_USE_CLOBBER_ARGV
        {
-               char       *cp;
+               int             buflen;
 
                /* pad unused memory */
-               for (cp = ps_buffer + strlen(ps_buffer);
-                        cp < ps_buffer + ps_buffer_size;
-                        cp++)
-                       *cp = PS_PADDING;
+               buflen = strlen(ps_buffer);
+               MemSet(ps_buffer + buflen, PS_PADDING, ps_buffer_size - buflen);
        }
 #endif   /* PS_USE_CLOBBER_ARGV */
 #endif   /* not PS_USE_NONE */