In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/4596752b8da44c630264e094a6e4a95082f0b07a?hp=f3b02925aeacaac5636cac62dc3bf78525fdbe3d>
- Log ----------------------------------------------------------------- commit 4596752b8da44c630264e094a6e4a95082f0b07a Author: Nicholas Clark <[email protected]> Date: Sun Mar 6 10:31:23 2011 +0000 A clearer layout for the fall-through logic of Socket::inet_aton() M ext/Socket/Socket.xs commit 013e295df0c07448c793c2b6d60b0a2400261e88 Author: Nicholas Clark <[email protected]> Date: Sun Mar 6 10:16:22 2011 +0000 In inet_aton(), use newSVpvn_flags() instead of sv_newmortal(), sv_setpvn() The API calls are equivalent, but the object code is slightly smaller. M ext/Socket/Socket.xs ----------------------------------------------------------------------- Summary of changes: ext/Socket/Socket.xs | 18 ++++++++++-------- 1 files changed, 10 insertions(+), 8 deletions(-) diff --git a/ext/Socket/Socket.xs b/ext/Socket/Socket.xs index e9a8c56..9214fc1 100644 --- a/ext/Socket/Socket.xs +++ b/ext/Socket/Socket.xs @@ -423,17 +423,19 @@ inet_aton(host) { struct in_addr ip_address; struct hostent * phe; - int ok = (*host != '\0') && inet_aton(host, &ip_address); - if (!ok && (phe = gethostbyname(host)) && - phe->h_addrtype == AF_INET && phe->h_length == 4) { - Copy( phe->h_addr, &ip_address, phe->h_length, char ); - ok = 1; + if ((*host != '\0') && inet_aton(host, &ip_address)) { + ST(0) = newSVpvn_flags((char *)&ip_address, sizeof ip_address, SVs_TEMP); + XSRETURN(1); + } + + phe = gethostbyname(host); + if (phe && phe->h_addrtype == AF_INET && phe->h_length == 4) { + ST(0) = newSVpvn_flags((char *)phe->h_addr, phe->h_length, SVs_TEMP); + XSRETURN(1); } - ST(0) = sv_newmortal(); - if (ok) - sv_setpvn( ST(0), (char *)&ip_address, sizeof ip_address ); + XSRETURN_UNDEF; } void -- Perl5 Master Repository
