hv_stores() on a literal string is now fractionally more efficient than
authorNicholas Clark <nick@ccl4.org>
Fri, 21 Sep 2007 09:16:37 +0000 (09:16 +0000)
committerNicholas Clark <nick@ccl4.org>
Fri, 21 Sep 2007 09:16:37 +0000 (09:16 +0000)
hv_store().

p4raw-id: //depot/perl@31938

mg.c
util.c

diff --git a/mg.c b/mg.c
index 8b790c0..128f2a2 100644 (file)
--- a/mg.c
+++ b/mg.c
@@ -2866,15 +2866,15 @@ Perl_sighandler(int sig)
                   SV *rv  = newRV_noinc((SV*)sih);
                   /* The siginfo fields signo, code, errno, pid, uid,
                    * addr, status, and band are defined by POSIX/SUSv3. */
-                  (void)hv_store(sih, "signo", 5, newSViv(sip->si_signo), 0);
-                  (void)hv_store(sih, "code",  4, newSViv(sip->si_code),  0);
+                  (void)hv_stores(sih, "signo", newSViv(sip->si_signo));
+                  (void)hv_stores(sih, "code", newSViv(sip->si_code));
 #if 0 /* XXX TODO: Configure scan for the existence of these, but even that does not help if the SA_SIGINFO is not implemented according to the spec. */
-                  hv_store(sih, "errno",   5, newSViv(sip->si_errno),  0);
-                  hv_store(sih, "status",  6, newSViv(sip->si_status), 0);
-                  hv_store(sih, "uid",     3, newSViv(sip->si_uid),    0);
-                  hv_store(sih, "pid",     3, newSViv(sip->si_pid),    0);
-                  hv_store(sih, "addr",    4, newSVuv(PTR2UV(sip->si_addr)),   0);
-                  hv_store(sih, "band",    4, newSViv(sip->si_band),   0);
+                  hv_stores(sih, "errno",      newSViv(sip->si_errno));
+                  hv_stores(sih, "status",     newSViv(sip->si_status));
+                  hv_stores(sih, "uid",        newSViv(sip->si_uid));
+                  hv_stores(sih, "pid",        newSViv(sip->si_pid));
+                  hv_stores(sih, "addr",       newSVuv(PTR2UV(sip->si_addr)));
+                  hv_stores(sih, "band",       newSViv(sip->si_band));
 #endif
                   EXTEND(SP, 2);
                   PUSHs((SV*)rv);
diff --git a/util.c b/util.c
index 7b5e2e8..83a6709 100644 (file)
--- a/util.c
+++ b/util.c
@@ -4225,11 +4225,11 @@ Perl_scan_version(pTHX_ const char *s, SV *rv, bool qv)
     pos = s;
 
     if ( qv )
-       (void)hv_store((HV *)hv, "qv", 2, newSViv(qv), 0);
+       (void)hv_stores((HV *)hv, "qv", newSViv(qv));
     if ( alpha )
-       (void)hv_store((HV *)hv, "alpha", 5, newSViv(alpha), 0);
+       (void)hv_stores((HV *)hv, "alpha", newSViv(alpha));
     if ( !qv && width < 3 )
-       (void)hv_store((HV *)hv, "width", 5, newSViv(width), 0);
+       (void)hv_stores((HV *)hv, "width", newSViv(width));
     
     while (isDIGIT(*pos))
        pos++;
@@ -4333,8 +4333,8 @@ Perl_scan_version(pTHX_ const char *s, SV *rv, bool qv)
     /* need to save off the current version string for later */
     if ( vinf ) {
        SV * orig = newSVpvn("v.Inf", sizeof("v.Inf")-1);
-       (void)hv_store((HV *)hv, "original", 8, orig, 0);
-       (void)hv_store((HV *)hv, "vinf", 4, newSViv(1), 0);
+       (void)hv_stores((HV *)hv, "original", orig);
+       (void)hv_stores((HV *)hv, "vinf", newSViv(1));
     }
     else if ( s > start ) {
        SV * orig = newSVpvn(start,s-start);
@@ -4342,15 +4342,15 @@ Perl_scan_version(pTHX_ const char *s, SV *rv, bool qv)
            /* need to insert a v to be consistent */
            sv_insert(orig, 0, 0, "v", 1);
        }
-       (void)hv_store((HV *)hv, "original", 8, orig, 0);
+       (void)hv_stores((HV *)hv, "original", orig);
     }
     else {
-       (void)hv_store((HV *)hv, "original", 8, newSVpvn("0",1), 0);
+       (void)hv_stores((HV *)hv, "original", newSVpvn("0",1));
        av_push(av, newSViv(0));
     }
 
     /* And finally, store the AV in the hash */
-    (void)hv_store((HV *)hv, "version", 7, newRV_noinc((SV *)av), 0);
+    (void)hv_stores((HV *)hv, "version", newRV_noinc((SV *)av));
 
     /* fix RT#19517 - special case 'undef' as string */
     if ( *s == 'u' && strEQ(s,"undef") ) {
@@ -4395,21 +4395,21 @@ Perl_new_version(pTHX_ SV *ver)
 
        /* Begin copying all of the elements */
        if ( hv_exists((HV *)ver, "qv", 2) )
-           (void)hv_store((HV *)hv, "qv", 2, &PL_sv_yes, 0);
+           (void)hv_stores((HV *)hv, "qv", &PL_sv_yes);
 
        if ( hv_exists((HV *)ver, "alpha", 5) )
-           (void)hv_store((HV *)hv, "alpha", 5, &PL_sv_yes, 0);
+           (void)hv_stores((HV *)hv, "alpha", &PL_sv_yes);
        
        if ( hv_exists((HV*)ver, "width", 5 ) )
        {
            const I32 width = SvIV(*hv_fetchs((HV*)ver, "width", FALSE));
-           (void)hv_store((HV *)hv, "width", 5, newSViv(width), 0);
+           (void)hv_stores((HV *)hv, "width", newSViv(width));
        }
 
        if ( hv_exists((HV*)ver, "original", 8 ) )
        {
            SV * pv = *hv_fetchs((HV*)ver, "original", FALSE);
-           (void)hv_store((HV *)hv, "original", 8, newSVsv(pv), 0);
+           (void)hv_stores((HV *)hv, "original", newSVsv(pv));
        }
 
        sav = (AV *)SvRV(*hv_fetchs((HV*)ver, "version", FALSE));
@@ -4420,7 +4420,7 @@ Perl_new_version(pTHX_ SV *ver)
            av_push(av, newSViv(rev));
        }
 
-       (void)hv_store((HV *)hv, "version", 7, newRV_noinc((SV *)av), 0);
+       (void)hv_stores((HV *)hv, "version", newRV_noinc((SV *)av));
        return rv;
     }
 #ifdef SvVOK