summaryrefslogtreecommitdiff
path: root/perl.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2007-10-18 07:17:46 +0000
committerNicholas Clark <nick@ccl4.org>2007-10-18 07:17:46 +0000
commitb64cb68ca7e876fc8f2b14e3631335667b719e7e (patch)
tree3bac56760f8bfafbfd8ad682b7f33bcba1d1acec /perl.c
parent82d8bb4934a8ea558df654435885eafe94e09dc8 (diff)
downloadperl-b64cb68ca7e876fc8f2b14e3631335667b719e7e.tar.gz
In Perl_moreswitches(), avoid the strlen() inside sv_catpv() by moving
the strlen() earlier. Brought to you by the Campaign for the Elimination of strlen(). p4raw-id: //depot/perl@32126
Diffstat (limited to 'perl.c')
-rw-r--r--perl.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/perl.c b/perl.c
index d62b3bdbf5..d2d748f182 100644
--- a/perl.c
+++ b/perl.c
@@ -3167,6 +3167,7 @@ Perl_moreswitches(pTHX_ const char *s)
forbid_setid('m', -1); /* XXX ? */
if (*++s) {
const char *start;
+ const char *end;
SV *sv;
const char *use = "use ";
/* -M-foo == 'no foo' */
@@ -3177,8 +3178,9 @@ Perl_moreswitches(pTHX_ const char *s)
start = s;
/* We allow -M'Module qw(Foo Bar)' */
while(isALNUM(*s) || *s==':') ++s;
+ end = s + strlen(s);
if (*s != '=') {
- sv_catpv(sv, start);
+ sv_catpvn(sv, start, end - start);
if (*(start-1) == 'm') {
if (*s != '\0')
Perl_croak(aTHX_ "Can't use '%c' after -mname", *s);
@@ -3189,12 +3191,13 @@ Perl_moreswitches(pTHX_ const char *s)
Perl_croak(aTHX_ "Module name required with -%c option",
s[-1]);
sv_catpvn(sv, start, s-start);
- sv_catpvs(sv, " split(/,/,q");
- sv_catpvs(sv, "\0"); /* Use NUL as q//-delimiter. */
- sv_catpv(sv, ++s);
+ /* Use NUL as q''-delimiter. */
+ sv_catpvs(sv, " split(/,/,q\0");
+ ++s;
+ sv_catpvn(sv, s, end - s);
sv_catpvs(sv, "\0)");
}
- s += strlen(s);
+ s = end;
Perl_av_create_and_push(aTHX_ &PL_preambleav, sv);
}
else