From: H.Merijn Brand Date: Fri, 7 Feb 2003 09:57:43 +0000 (+0100) Subject: More code cleanup. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=4db098f469629e77d52348ce8cf58b861a065397;p=p5sagit%2Fp5-mst-13.2.git More code cleanup. Subject: Re: New SV Flag From: "H.Merijn Brand" Message-Id: <20030207095258.6E05.H.M.BRAND@hccnet.nl> p4raw-id: //depot/perl@18693 --- diff --git a/sv.c b/sv.c index 6c8eb65..4ef0485 100644 --- a/sv.c +++ b/sv.c @@ -5398,7 +5398,7 @@ SV * Perl_sv_newref(pTHX_ SV *sv) { if (sv) - ATOMIC_INC(SvREFCNT(sv)); + (SvREFCNT(sv))++; return sv; } @@ -5416,8 +5416,6 @@ Normally called via a wrapper macro C. void Perl_sv_free(pTHX_ SV *sv) { - int refcount_is_zero; - if (!sv) return; if (SvREFCNT(sv) == 0) { @@ -5436,8 +5434,7 @@ Perl_sv_free(pTHX_ SV *sv) Perl_warner(aTHX_ packWARN(WARN_INTERNAL), "Attempt to free unreferenced scalar"); return; } - ATOMIC_DEC_AND_TEST(refcount_is_zero, SvREFCNT(sv)); - if (!refcount_is_zero) + if (--(SvREFCNT(sv)) > 0) return; #ifdef DEBUGGING if (SvTEMP(sv)) { diff --git a/sv.h b/sv.h index 82ef302..3ba04fe 100644 --- a/sv.h +++ b/sv.h @@ -125,20 +125,17 @@ perform the upgrade if necessary. See C. #define SvFLAGS(sv) (sv)->sv_flags #define SvREFCNT(sv) (sv)->sv_refcnt -#define ATOMIC_INC(count) (++count) -#define ATOMIC_DEC_AND_TEST(res, count) (res = (--count == 0)) - #if defined(__GNUC__) && !defined(__STRICT_ANSI__) && !defined(PERL_GCC_PEDANTIC) # define SvREFCNT_inc(sv) \ ({ \ SV *nsv = (SV*)(sv); \ if (nsv) \ - ATOMIC_INC(SvREFCNT(nsv)); \ + (SvREFCNT(nsv))++; \ nsv; \ }) #else # define SvREFCNT_inc(sv) \ - ((PL_Sv=(SV*)(sv)), (PL_Sv && ATOMIC_INC(SvREFCNT(PL_Sv))), (SV*)PL_Sv) + ((PL_Sv=(SV*)(sv)), (PL_Sv && ++(SvREFCNT(PL_Sv))), (SV*)PL_Sv) #endif #define SvREFCNT_dec(sv) sv_free((SV*)(sv))