diff options
author | Nicholas Clark <nick@ccl4.org> | 2006-01-28 13:38:28 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2006-01-28 13:38:28 +0000 |
commit | 4f2da183afece5ce28d1dcdb66d8d931eb0d976a (patch) | |
tree | 0ac0c94cde46c822be65a07383ae61e30a90a9dd /util.c | |
parent | b8473700d76df372cb0ff6b7c4953731e2d985c2 (diff) | |
download | perl-4f2da183afece5ce28d1dcdb66d8d931eb0d976a.tar.gz |
By changing SvVOK() from returning 0/1 to 0/pointer-to-magic we can
save duplicating mg_find calls, without changing the semantics in any
boolean context.
p4raw-id: //depot/perl@26979
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 26 |
1 files changed, 15 insertions, 11 deletions
@@ -4170,17 +4170,19 @@ Perl_new_version(pTHX_ SV *ver) return rv; } #ifdef SvVOK - if ( SvVOK(ver) ) { /* already a v-string */ - const MAGIC* const mg = mg_find(ver,PERL_MAGIC_vstring); - const STRLEN len = mg->mg_len; - char * const version = savepvn( (const char*)mg->mg_ptr, len); - sv_setpvn(rv,version,len); - Safefree(version); - } - else { + { + const MAGIC* const mg = SvVOK(ver); + if ( mg ) { /* already a v-string */ + const STRLEN len = mg->mg_len; + char * const version = savepvn( (const char*)mg->mg_ptr, len); + sv_setpvn(rv,version,len); + Safefree(version); + } + else { #endif - sv_setsv(rv,ver); /* make a duplicate */ + sv_setsv(rv,ver); /* make a duplicate */ #ifdef SvVOK + } } #endif return upg_version(rv); @@ -4203,6 +4205,9 @@ Perl_upg_version(pTHX_ SV *ver) { const char *version, *s; bool qv = 0; +#ifdef SvVOK + const MAGIC *mg; +#endif if ( SvNOK(ver) ) /* may get too much accuracy */ { @@ -4211,8 +4216,7 @@ Perl_upg_version(pTHX_ SV *ver) version = savepvn(tbuf, len); } #ifdef SvVOK - else if ( SvVOK(ver) ) { /* already a v-string */ - const MAGIC* const mg = mg_find(ver,PERL_MAGIC_vstring); + else if ( (mg = SvVOK(ver)) ) { /* already a v-string */ version = savepvn( (const char*)mg->mg_ptr,mg->mg_len ); qv = 1; } |