This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Change newSVpv() to newSVpvn() where we know the length is non-zero, as
authorNicholas Clark <nick@ccl4.org>
Thu, 18 Oct 2007 17:15:16 +0000 (17:15 +0000)
committerNicholas Clark <nick@ccl4.org>
Thu, 18 Oct 2007 17:15:16 +0000 (17:15 +0000)
newSVpvn() will be fractionally more efficient.

p4raw-id: //depot/perl@32135

mg.c
toke.c

diff --git a/mg.c b/mg.c
index 4e3504c..00b0c71 100644 (file)
--- a/mg.c
+++ b/mg.c
@@ -1245,7 +1245,7 @@ Perl_magic_clearsig(pTHX_ SV *sv, MAGIC *mg)
            sigaddset(&set,i);
            sigprocmask(SIG_BLOCK, &set, &save);
            ENTER;
-           save_sv = newSVpv((char *)(&save), sizeof(sigset_t));
+           save_sv = newSVpvn((char *)(&save), sizeof(sigset_t));
            SAVEFREESV(save_sv);
            SAVEDESTRUCTOR_X(restore_sigmask, save_sv);
 #endif
@@ -1442,7 +1442,7 @@ Perl_magic_setsig(pTHX_ SV *sv, MAGIC *mg)
        sigaddset(&set,i);
        sigprocmask(SIG_BLOCK, &set, &save);
        ENTER;
-       save_sv = newSVpv((char *)(&save), sizeof(sigset_t));
+       save_sv = newSVpvn((char *)(&save), sizeof(sigset_t));
        SAVEFREESV(save_sv);
        SAVEDESTRUCTOR_X(restore_sigmask, save_sv);
 #endif
@@ -2876,7 +2876,7 @@ Perl_sighandler(int sig)
 #endif
                   EXTEND(SP, 2);
                   PUSHs((SV*)rv);
-                  PUSHs(newSVpv((char *)sip, sizeof(*sip)));
+                  PUSHs(newSVpvn((char *)sip, sizeof(*sip)));
              }
 
         }
diff --git a/toke.c b/toke.c
index eb7c18c..f8d207c 100644 (file)
--- a/toke.c
+++ b/toke.c
@@ -5346,7 +5346,7 @@ Perl_yylex(pTHX)
 #ifdef PERL_MAD
                if (PL_madskills && !PL_thistoken) {
                    char *start = SvPVX(PL_linestr) + PL_realtokenstart;
-                   PL_thistoken = newSVpv(start,s - start);
+                   PL_thistoken = newSVpvn(start,s - start);
                    PL_realtokenstart = s - SvPVX(PL_linestr);
                }
 #endif