From: Vincent Pit Date: Tue, 3 Mar 2009 00:38:22 +0000 (+0100) Subject: Clean up the remaining if (...) { ... } tests X-Git-Tag: v0.33~16 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=c2588a284fafc441108ad2505f786dfa74de4d70;p=perl%2Fmodules%2FVariable-Magic.git Clean up the remaining if (...) { ... } tests --- diff --git a/Magic.xs b/Magic.xs index 814a6af..ab8a1c5 100644 --- a/Magic.xs +++ b/Magic.xs @@ -514,7 +514,8 @@ STATIC UV vmg_cast(pTHX_ SV *sv, SV *wiz, AV *args) { /* One uvar magic in the chain is enough. */ for (prevmagic = NULL, mg = SvMAGIC(sv); mg; prevmagic = mg, mg = moremagic) { moremagic = mg->mg_moremagic; - if (mg->mg_type == PERL_MAGIC_uvar) { break; } + if (mg->mg_type == PERL_MAGIC_uvar) + break; } if (mg) { /* Found another uvar magic. */ @@ -546,7 +547,8 @@ STATIC UV vmg_dispell(pTHX_ SV *sv, U16 sig) { #endif /* VMG_UVAR */ MAGIC *mg, *prevmagic, *moremagic = NULL; - if (SvTYPE(sv) < SVt_PVMG) { return 0; } + if (SvTYPE(sv) < SVt_PVMG) + return 0; for (prevmagic = NULL, mg = SvMAGIC(sv); mg; prevmagic = mg, mg = moremagic) { moremagic = mg->mg_moremagic; @@ -566,7 +568,8 @@ STATIC UV vmg_dispell(pTHX_ SV *sv, U16 sig) { } } } - if (!mg) { return 0; } + if (!mg) + return 0; if (prevmagic) { prevmagic->mg_moremagic = moremagic; @@ -575,8 +578,11 @@ STATIC UV vmg_dispell(pTHX_ SV *sv, U16 sig) { } mg->mg_moremagic = NULL; - if (mg->mg_obj != sv) { SvREFCNT_dec(mg->mg_obj); } /* Destroy private data */ - SvREFCNT_dec((SV *) mg->mg_ptr); /* Unreference the wizard */ + /* Destroy private data */ + if (mg->mg_obj != sv) + SvREFCNT_dec(mg->mg_obj); + /* Unreference the wizard */ + SvREFCNT_dec((SV *) mg->mg_ptr); Safefree(mg); #if VMG_UVAR @@ -597,7 +603,8 @@ STATIC UV vmg_dispell(pTHX_ SV *sv, U16 sig) { struct ufuncs *uf; for (prevmagic = NULL, mg = SvMAGIC(sv); mg; prevmagic = mg, mg = moremagic){ moremagic = mg->mg_moremagic; - if (mg->mg_type == PERL_MAGIC_uvar) { break; } + if (mg->mg_type == PERL_MAGIC_uvar) + break; } /* assert(mg); */ uf = (struct ufuncs *) mg->mg_ptr; @@ -929,8 +936,10 @@ STATIC I32 vmg_svt_val(pTHX_ IV action, SV *sv) { key = umg->mg_obj; uf = (struct ufuncs *) umg->mg_ptr; - if (uf[1].uf_val != NULL) { uf[1].uf_val(aTHX_ action, sv); } - if (uf[1].uf_set != NULL) { uf[1].uf_set(aTHX_ action, sv); } + if (uf[1].uf_val) + uf[1].uf_val(aTHX_ action, sv); + if (uf[1].uf_set) + uf[1].uf_set(aTHX_ action, sv); action &= HV_FETCH_ISSTORE | HV_FETCH_ISEXISTS | HV_FETCH_LVALUE | HV_DELETE; for (mg = SvMAGIC(sv); mg; mg = mg->mg_moremagic) { @@ -1022,26 +1031,26 @@ STATIC int vmg_wizard_free(pTHX_ SV *wiz, MAGIC *mg) { SvFLAGS(wiz) |= SVf_BREAK; FREETMPS; - if (w->cb_data != NULL) { SvREFCNT_dec(SvRV(w->cb_data)); } - if (w->cb_get != NULL) { SvREFCNT_dec(SvRV(w->cb_get)); } - if (w->cb_set != NULL) { SvREFCNT_dec(SvRV(w->cb_set)); } - if (w->cb_len != NULL) { SvREFCNT_dec(SvRV(w->cb_len)); } - if (w->cb_clear != NULL) { SvREFCNT_dec(SvRV(w->cb_clear)); } - if (w->cb_free != NULL) { SvREFCNT_dec(SvRV(w->cb_free)); } + if (w->cb_data) SvREFCNT_dec(SvRV(w->cb_data)); + if (w->cb_get) SvREFCNT_dec(SvRV(w->cb_get)); + if (w->cb_set) SvREFCNT_dec(SvRV(w->cb_set)); + if (w->cb_len) SvREFCNT_dec(SvRV(w->cb_len)); + if (w->cb_clear) SvREFCNT_dec(SvRV(w->cb_clear)); + if (w->cb_free) SvREFCNT_dec(SvRV(w->cb_free)); #if MGf_COPY - if (w->cb_copy != NULL) { SvREFCNT_dec(SvRV(w->cb_copy)); } + if (w->cb_copy) SvREFCNT_dec(SvRV(w->cb_copy)); #endif /* MGf_COPY */ #if 0 /* MGf_DUP */ - if (w->cb_dup != NULL) { SvREFCNT_dec(SvRV(w->cb_dup)); } + if (w->cb_dup) SvREFCNT_dec(SvRV(w->cb_dup)); #endif /* MGf_DUP */ #if MGf_LOCAL - if (w->cb_local != NULL) { SvREFCNT_dec(SvRV(w->cb_local)); } + if (w->cb_local) SvREFCNT_dec(SvRV(w->cb_local)); #endif /* MGf_LOCAL */ #if VMG_UVAR - if (w->cb_fetch != NULL) { SvREFCNT_dec(SvRV(w->cb_fetch)); } - if (w->cb_store != NULL) { SvREFCNT_dec(SvRV(w->cb_store)); } - if (w->cb_exists != NULL) { SvREFCNT_dec(SvRV(w->cb_exists)); } - if (w->cb_delete != NULL) { SvREFCNT_dec(SvRV(w->cb_delete)); } + if (w->cb_fetch) SvREFCNT_dec(SvRV(w->cb_fetch)); + if (w->cb_store) SvREFCNT_dec(SvRV(w->cb_store)); + if (w->cb_exists) SvREFCNT_dec(SvRV(w->cb_exists)); + if (w->cb_delete) SvREFCNT_dec(SvRV(w->cb_delete)); #endif /* VMG_UVAR */ Safefree(w->vtbl); @@ -1400,7 +1409,8 @@ OUTPUT: SV *getsig(SV *wiz) PROTOTYPE: $ CODE: - if (!SvROK(wiz)) { croak(vmg_invalid_wiz); } + if (!SvROK(wiz)) + croak(vmg_invalid_wiz); RETVAL = newSVuv(SV2MGWIZ(SvRV(wiz))->sig); OUTPUT: RETVAL @@ -1419,7 +1429,7 @@ CODE: for (i = 2; i < items; ++i) { SV *arg = ST(i); SvREFCNT_inc(arg); - if (av_store(args, i - 2, arg) == NULL) { croak(vmg_argstorefailed); } + if (av_store(args, i - 2, arg) == NULL) croak(vmg_argstorefailed); } } ret = newSVuv(vmg_cast(SvRV(sv), wiz, args)); @@ -1437,7 +1447,8 @@ PREINIT: PPCODE: sig = vmg_wizard_sig(wiz); data = vmg_data_get(SvRV(sv), sig); - if (!data) { XSRETURN_UNDEF; } + if (!data) + XSRETURN_UNDEF; ST(0) = data; XSRETURN(1);