From: Vincent Pit Date: Sat, 1 Jan 2011 22:28:48 +0000 (+0100) Subject: Only declare dMY_CXT when really needed X-Git-Tag: v0.10~12 X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2FLexical-Types.git;a=commitdiff_plain;h=0dcfddc6bb7dd1913079233b16233f4b359162b4 Only declare dMY_CXT when really needed --- diff --git a/Types.xs b/Types.xs index b3412b5..73cacfc 100644 --- a/Types.xs +++ b/Types.xs @@ -284,9 +284,6 @@ STATIC SV *lt_tag(pTHX_ SV *value) { #define lt_tag(V) lt_tag(aTHX_ (V)) lt_hint_t *h; SV *code = NULL; -#if LT_THREADSAFE - dMY_CXT; -#endif if (SvROK(value)) { value = SvRV(value); @@ -307,10 +304,13 @@ STATIC SV *lt_tag(pTHX_ SV *value) { #endif /* !LT_HINT_STRUCT */ #if LT_THREADSAFE - /* We only need for the key to be an unique tag for looking up the value later. - * Allocated memory provides convenient unique identifiers, so that's why we - * use the hint as the key itself. */ - ptable_hints_store(MY_CXT.tbl, h, h); + { + dMY_CXT; + /* We only need for the key to be an unique tag for looking up the value later + * Allocated memory provides convenient unique identifiers, so that's why we + * use the hint as the key itself. */ + ptable_hints_store(MY_CXT.tbl, h, h); + } #endif /* LT_THREADSAFE */ return newSViv(PTR2IV(h)); @@ -562,12 +562,12 @@ STATIC OP *(*lt_old_ck_padany)(pTHX_ OP *) = 0; STATIC OP *lt_ck_padany(pTHX_ OP *o) { HV *stash; SV *code; - dMY_CXT; o = lt_old_ck_padany(aTHX_ o); stash = PL_in_my_stash; if (stash && (code = lt_hint())) { + dMY_CXT; SV *orig_pkg = newSVpvn(HvNAME_get(stash), HvNAMELEN_get(stash)); SV *orig_meth = MY_CXT.default_meth; SV *type_pkg = NULL; @@ -639,8 +639,6 @@ skip: STATIC OP *(*lt_old_ck_padsv)(pTHX_ OP *) = 0; STATIC OP *lt_ck_padsv(pTHX_ OP *o) { - dMY_CXT; - lt_map_delete(o); return lt_old_ck_padsv(aTHX_ o); @@ -749,8 +747,6 @@ STATIC void lt_peep(pTHX_ OP *o) { STATIC U32 lt_initialized = 0; STATIC void lt_teardown(pTHX_ void *root) { - dMY_CXT; - if (!lt_initialized) return; @@ -759,13 +755,16 @@ STATIC void lt_teardown(pTHX_ void *root) { return; #endif + { + dMY_CXT; #if LT_THREADSAFE - ptable_hints_free(MY_CXT.tbl); + ptable_hints_free(MY_CXT.tbl); #endif #if !LT_HAS_RPEEP - ptable_seen_free(MY_CXT.seen); + ptable_seen_free(MY_CXT.seen); #endif - SvREFCNT_dec(MY_CXT.default_meth); + SvREFCNT_dec(MY_CXT.default_meth); + } PL_check[OP_PADANY] = MEMBER_TO_FPTR(lt_old_ck_padany); lt_old_ck_padany = 0;