In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/23933b71b68b2a941ad96656d331a8c2775288cc?hp=0de694c509edaf65aac76fe7d6e192754c4b6adc>

- Log -----------------------------------------------------------------
commit 23933b71b68b2a941ad96656d331a8c2775288cc
Author: Nicholas Clark <[email protected]>
Date:   Thu Oct 21 17:58:42 2010 +0100

    Sys::Hostname::ghname should use newSVpv(s, 0), not newSVpvn(s, strlen(s))
    
    Whilst functionally identical, the latter will produce more object code.
    Also, avoid the strlen() entirely for the case of HAS_PHOSTNAME, where we 
know
    the length.
-----------------------------------------------------------------------

Summary of changes:
 ext/Sys-Hostname/Hostname.xs |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/ext/Sys-Hostname/Hostname.xs b/ext/Sys-Hostname/Hostname.xs
index 23ecd69..3ec72f7 100644
--- a/ext/Sys-Hostname/Hostname.xs
+++ b/ext/Sys-Hostname/Hostname.xs
@@ -35,7 +35,7 @@ ghname()
     {
        char tmps[MAXHOSTNAMELEN];
        retval = PerlSock_gethostname(tmps, sizeof(tmps));
-       sv = newSVpvn(tmps, strlen(tmps));
+       sv = newSVpv(tmps, 0);
     }
 #else
 #  ifdef HAS_PHOSTNAME
@@ -53,9 +53,8 @@ ghname()
            *p++ = c;
        }
        PerlProc_pclose(io);
-       *p = '\0';
        retval = 0;
-       sv = newSVpvn(tmps, strlen(tmps));
+       sv = newSVpvn(tmps, p - tmps);
     }
 #  else
 #    ifdef HAS_UNAME
@@ -63,7 +62,7 @@ ghname()
        struct utsname u;
        if (PerlEnv_uname(&u) == -1)
            goto check_out;
-       sv = newSVpvn(u.nodename, strlen(u.nodename));
+       sv = newSVpv(u.nodename, 0);
         retval = 0;
     }
 #    endif

--
Perl5 Master Repository

Reply via email to