From: Nicholas Clark Date: Tue, 16 Oct 2007 09:38:48 +0000 (+0000) Subject: Moving a strlen() in Perl_moreswitches() saves a strlen() in sv_catpv() X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f85893a12feb8ca0f4e9b625542f3ff2920ac00c;p=p5sagit%2Fp5-mst-13.2.git Moving a strlen() in Perl_moreswitches() saves a strlen() in sv_catpv() Brought to you by the Campaign for the Elimination of strlen(). p4raw-id: //depot/perl@32112 --- diff --git a/perl.c b/perl.c index bb35671..d62b3bd 100644 --- a/perl.c +++ b/perl.c @@ -3050,20 +3050,21 @@ Perl_moreswitches(pTHX_ const char *s) /* The following permits -d:Mod to accepts arguments following an = in the fashion that -MSome::Mod does. */ if (*s == ':' || *s == '=') { - const char *start; + const char *start = ++s; + const char *const end = s + strlen(s); SV * const sv = newSVpvs("use Devel::"); - start = ++s; + /* We now allow -d:Module=Foo,Bar */ while(isALNUM(*s) || *s==':') ++s; if (*s != '=') - sv_catpv(sv, start); + sv_catpvn(sv, start, end - start); else { sv_catpvn(sv, start, s-start); /* Don't use NUL as q// delimiter here, this string goes in the * environment. */ Perl_sv_catpvf(aTHX_ sv, " split(/,/,q{%s});", ++s); } - s += strlen(s); + s = end; my_setenv("PERL5DB", SvPV_nolen_const(sv)); SvREFCNT_dec(sv); }