From: Nicholas Clark Date: Tue, 7 Jun 2005 15:10:38 +0000 (+0000) Subject: Simplify the implementation of SvPV*nolen functions X-Git-Tag: accepted/trunk/20130322.191538~20519 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=dafda6d147bb18b3050b636ac1d31818028dd936;p=platform%2Fupstream%2Fperl.git Simplify the implementation of SvPV*nolen functions p4raw-id: //depot/perl@24733 --- diff --git a/sv.c b/sv.c index 81634de..4e9c3f9 100644 --- a/sv.c +++ b/sv.c @@ -3328,8 +3328,7 @@ use the macro wrapper C instead. char * Perl_sv_2pv_nolen(pTHX_ register SV *sv) { - STRLEN n_a; - return sv_2pv(sv, &n_a); + return sv_2pv(sv, 0); } /* uiv_2buf(): private routine for use by sv_2pv_flags(): print an IV or @@ -3394,6 +3393,12 @@ Perl_sv_2pv_flags(pTHX_ register SV *sv, STRLEN *lp, I32 flags) SV *tsv, *origsv; char tbuf[64]; /* Must fit sprintf/Gconvert of longest IV/NV */ char *tmpbuf = tbuf; + STRLEN n_a; + + if (!lp) { + /* Saves needing to do lots of if (!lp) checks below */ + lp = &n_a; + } if (!sv) { *lp = 0; @@ -3728,8 +3733,7 @@ Usually accessed via the C macro. char * Perl_sv_2pvbyte_nolen(pTHX_ register SV *sv) { - STRLEN n_a; - return sv_2pvbyte(sv, &n_a); + return sv_2pvbyte(sv, 0); } /* @@ -3765,8 +3769,7 @@ Usually accessed via the C macro. char * Perl_sv_2pvutf8_nolen(pTHX_ register SV *sv) { - STRLEN n_a; - return sv_2pvutf8(sv, &n_a); + return sv_2pvutf8(sv, 0); } /* diff --git a/sv.h b/sv.h index 19acb1a..377f9a3 100644 --- a/sv.h +++ b/sv.h @@ -1222,7 +1222,7 @@ Like C but doesn't process magic. #define SvPV_nolen(sv) \ ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \ - ? SvPVX(sv) : sv_2pv_nolen(sv)) + ? SvPVX(sv) : sv_2pv_flags(sv, 0, SV_GMAGIC)) #define SvPV_nomg(sv, lp) SvPV_flags(sv, lp, 0) @@ -1239,7 +1239,7 @@ Like C but doesn't process magic. #define SvPVutf8_nolen(sv) \ ((SvFLAGS(sv) & (SVf_POK|SVf_UTF8)) == (SVf_POK|SVf_UTF8)\ - ? SvPVX(sv) : sv_2pvutf8_nolen(sv)) + ? SvPVX(sv) : sv_2pvutf8(sv, 0)) /* ----*/ @@ -1253,7 +1253,7 @@ Like C but doesn't process magic. #define SvPVbyte_nolen(sv) \ ((SvFLAGS(sv) & (SVf_POK|SVf_UTF8)) == (SVf_POK)\ - ? SvPVX(sv) : sv_2pvbyte_nolen(sv)) + ? SvPVX(sv) : sv_2pvbyte(sv, 0))