This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Refactor B::hash to use Perl_newSVpvf() instead of my_sprintf() and new_SVpvn*.
authorNicholas Clark <nick@ccl4.org>
Sun, 24 Oct 2010 14:23:05 +0000 (16:23 +0200)
committerNicholas Clark <nick@ccl4.org>
Sun, 24 Oct 2010 14:23:05 +0000 (16:23 +0200)
ext/B/B.xs

index 138ec05..28ad952 100644 (file)
@@ -781,11 +781,9 @@ hash(sv)
     CODE:
        STRLEN len;
        U32 hash = 0;
-       char hexhash[19]; /* must fit "0xffffffffffffffff" plus trailing \0 */
        const char *s = SvPV(sv, len);
        PERL_HASH(hash, s, len);
-       len = my_sprintf(hexhash, "0x%"UVxf, (UV)hash);
-       ST(0) = newSVpvn_flags(hexhash, len, SVs_TEMP);
+       ST(0) = sv_2mortal(Perl_newSVpvf(aTHX_ "0x%"UVxf, (UV)hash));
 
 #define cast_I32(foo) (I32)foo
 IV