From: Neil Conway Date: Sat, 12 Jan 2008 10:38:32 +0000 (+0000) Subject: Minor perf tweak for _SPI_strdup(): if we're going to call strlen() X-Git-Tag: REL8_3_RC2~35 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=25b7583f67136e522b502ee2ad32ae630e521439;p=postgresql Minor perf tweak for _SPI_strdup(): if we're going to call strlen() anyway, it is faster to memcpy() than to strcpy(). --- diff --git a/src/backend/utils/adt/xml.c b/src/backend/utils/adt/xml.c index f61c666903..295e826576 100644 --- a/src/backend/utils/adt/xml.c +++ b/src/backend/utils/adt/xml.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/backend/utils/adt/xml.c,v 1.64 2008/01/01 19:45:53 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/xml.c,v 1.65 2008/01/12 10:38:32 neilc Exp $ * *------------------------------------------------------------------------- */ @@ -1821,9 +1821,10 @@ map_sql_value_to_xml_value(Datum value, Oid type) static char * _SPI_strdup(const char *s) { - char *ret = SPI_palloc(strlen(s) + 1); + size_t len = strlen(s) + 1; + char *ret = SPI_palloc(len); - strcpy(ret, s); + memcpy(ret, s, len); return ret; }