In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/29912d932cee5589d4165d5eff62d0cc4f2c5195?hp=02e4b6fe3f1d559a97dee488594ffd93196f220b>

- Log -----------------------------------------------------------------
commit 29912d932cee5589d4165d5eff62d0cc4f2c5195
Author: Nicholas Clark <[email protected]>
Date:   Mon Oct 11 13:12:04 2010 +0100

    Avoid calling Gcovert() when stringifying 0.0 and -0.0
    
    Previously we always called Gconvert(), then tested its string output, then
    fixed that up if necessary. This way has fewer tests. We can also reduce the
    memory allocation for the string output for the case of zero.
-----------------------------------------------------------------------

Summary of changes:
 sv.c |   36 +++++++++++++++---------------------
 1 files changed, 15 insertions(+), 21 deletions(-)

diff --git a/sv.c b/sv.c
index 106fc18..8365664 100644
--- a/sv.c
+++ b/sv.c
@@ -2733,6 +2733,10 @@ Perl_sv_2pv_flags(pTHX_ register SV *const sv, STRLEN 
*const lp, const I32 flags
                len = SvIsUV(sv)
                    ? my_snprintf(tbuf, sizeof(tbuf), "%"UVuf, (UV)SvUVX(sv))
                    : my_snprintf(tbuf, sizeof(tbuf), "%"IVdf, (IV)SvIVX(sv));
+           } else if(SvNVX(sv) == 0.0) {
+                   tbuf[0] = '0';
+                   tbuf[1] = 0;
+                   len = 1;
            } else {
                Gconvert(SvNVX(sv), NV_DIG, 0, tbuf);
                len = strlen(tbuf);
@@ -2741,11 +2745,6 @@ Perl_sv_2pv_flags(pTHX_ register SV *const sv, STRLEN 
*const lp, const I32 flags
            {
                dVAR;
 
-               if (len == 2 && tbuf[0] == '-' && tbuf[1] == '0') {
-                   tbuf[0] = '0';
-                   tbuf[1] = 0;
-                   len = 1;
-               }
                SvUPGRADE(sv, SVt_PV);
                if (lp)
                    *lp = len;
@@ -2917,26 +2916,21 @@ Perl_sv_2pv_flags(pTHX_ register SV *const sv, STRLEN 
*const lp, const I32 flags
        *s = '\0';
     }
     else if (SvNOKp(sv)) {
-       dSAVE_ERRNO;
        if (SvTYPE(sv) < SVt_PVNV)
            sv_upgrade(sv, SVt_PVNV);
-       /* The +20 is pure guesswork.  Configure test needed. --jhi */
-       s = SvGROW_mutable(sv, NV_DIG + 20);
-       /* some Xenix systems wipe out errno here */
-#ifdef apollo
-       if (SvNVX(sv) == 0.0)
-           my_strlcpy(s, "0", SvLEN(sv));
-       else
-#endif /*apollo*/
-       {
+       if (SvNVX(sv) == 0.0) {
+           s = SvGROW_mutable(sv, 2);
+           *s++ = '0';
+           *s = '\0';
+       } else {
+           dSAVE_ERRNO;
+           /* The +20 is pure guesswork.  Configure test needed. --jhi */
+           s = SvGROW_mutable(sv, NV_DIG + 20);
+           /* some Xenix systems wipe out errno here */
            Gconvert(SvNVX(sv), NV_DIG, 0, s);
+           RESTORE_ERRNO;
+           while (*s) s++;
        }
-       RESTORE_ERRNO;
-        if (*s == '-' && s[1] == '0' && !s[2]) {
-           s[0] = '0';
-           s[1] = 0;
-       }
-       while (*s) s++;
 #ifdef hcx
        if (s[-1] == '.')
            *--s = '\0';

--
Perl5 Master Repository

Reply via email to