From: Doug MacEachern Date: Fri, 9 Nov 2001 18:13:18 +0000 (-0800) Subject: [patch] my_setenv speedup + fixes X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e658793210bbe632a5e80a876acfcd0984c46b87;p=p5sagit%2Fp5-mst-13.2.git [patch] my_setenv speedup + fixes Message-Id: p4raw-id: //depot/perl@12926 --- diff --git a/util.c b/util.c index c5b32e3..f1662c1 100644 --- a/util.c +++ b/util.c @@ -1496,6 +1496,16 @@ Perl_vwarner(pTHX_ U32 err, const char* pat, va_list* args) } } +/* since we've already done strlen() for both nam and val + * we can use that info to make things faster than + * sprintf(s, "%s=%s", nam, val) + */ +#define my_setenv_format(s, nam, nlen, val, vlen) \ + Copy(nam, s, nlen, char); \ + *(s+nlen) = '='; \ + Copy(val, s+(nlen+1), vlen, char); \ + *(s+(nlen+1+vlen)) = '\0' + #ifdef USE_ENVIRON_ARRAY /* VMS' and EPOC's my_setenv() is in vms.c and epoc.c */ #if !defined(WIN32) && !defined(NETWARE) @@ -1505,6 +1515,7 @@ Perl_my_setenv(pTHX_ char *nam, char *val) #ifndef PERL_USE_SAFE_PUTENV /* most putenv()s leak, so we manipulate environ directly */ register I32 i=setenv_getix(nam); /* where does it go? */ + int nlen, vlen; if (environ == PL_origenviron) { /* need we copy environment? */ I32 j; @@ -1515,8 +1526,9 @@ Perl_my_setenv(pTHX_ char *nam, char *val) for (max = i; environ[max]; max++) ; tmpenv = (char**)safesysmalloc((max+2) * sizeof(char*)); for (j=0; j