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

Commit 25b7583

Browse files
author
Neil Conway
committed
Minor perf tweak for _SPI_strdup(): if we're going to call strlen()
anyway, it is faster to memcpy() than to strcpy().
1 parent 208d0a2 commit 25b7583

File tree

1 file changed

+4
-3
lines changed
  • src/backend/utils/adt

1 file changed

+4
-3
lines changed

src/backend/utils/adt/xml.c

+4-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/backend/utils/adt/xml.c,v 1.64 2008/01/01 19:45:53 momjian Exp $
10+
* $PostgreSQL: pgsql/src/backend/utils/adt/xml.c,v 1.65 2008/01/12 10:38:32 neilc Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -1821,9 +1821,10 @@ map_sql_value_to_xml_value(Datum value, Oid type)
18211821
static char *
18221822
_SPI_strdup(const char *s)
18231823
{
1824-
char *ret = SPI_palloc(strlen(s) + 1);
1824+
size_t len = strlen(s) + 1;
1825+
char *ret = SPI_palloc(len);
18251826

1826-
strcpy(ret, s);
1827+
memcpy(ret, s, len);
18271828
return ret;
18281829
}
18291830

0 commit comments

Comments
 (0)