diff options
author | Nicolas R <atoomic@cpan.org> | 2017-09-18 14:37:48 -0600 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2017-09-21 07:07:49 -0700 |
commit | 79656330a0811b95642a8239e923166ada7fb0a0 (patch) | |
tree | f096cb3c9e14bfb87ea704d6c96027285aea6b12 /cv.h | |
parent | bd588a132b9686974e12bf262d1ba6c885895122 (diff) | |
download | perl-79656330a0811b95642a8239e923166ada7fb0a0.tar.gz |
Add CvGvNAME_HEK helper
CvGvNAME_HEK can be used instead of the boilerplate:
CvNAMED(sv) ? CvNAME_HEK((CV *)sv) : GvNAME_HEK(CvGV(sv))
This is also saving an extra CvNAMED check from CvNAME_HEK.
Diffstat (limited to 'cv.h')
-rw-r--r-- | cv.h | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -234,7 +234,17 @@ CvNAME_HEK(CV *sv) ? ((XPVCV*)MUTABLE_PTR(SvANY(sv)))->xcv_gv_u.xcv_hek : 0; } -/* This lowers the refernce count of the previous value, but does *not* + +/* helper for the common pattern: + CvNAMED(sv) ? CvNAME_HEK((CV *)sv) : GvNAME_HEK(CvGV(sv)) +*/ +#define CvGvNAME_HEK(sv) ( \ + CvNAMED((CV*)sv) ? \ + ((XPVCV*)MUTABLE_PTR(SvANY((SV*)sv)))->xcv_gv_u.xcv_hek\ + : GvNAME_HEK(CvGV( (SV*) sv)) \ + ) + +/* This lowers the reference count of the previous value, but does *not* increment the reference count of the new value. */ #define CvNAME_HEK_set(cv, hek) ( \ CvNAME_HEK((CV *)(cv)) \ |