]> git.vpit.fr Git - perl/modules/Lexical-Types.git/commitdiff
Only declare dMY_CXT when really needed
authorVincent Pit <vince@profvince.com>
Sat, 1 Jan 2011 22:28:48 +0000 (23:28 +0100)
committerVincent Pit <vince@profvince.com>
Sat, 1 Jan 2011 22:28:48 +0000 (23:28 +0100)
Types.xs

index b3412b55e66d8bf9f432121e169941724033a592..73cacfca18f300e244651da527bd134abe06a57f 100644 (file)
--- 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;
 #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);
 
  if (SvROK(value)) {
   value = SvRV(value);
@@ -307,10 +304,13 @@ STATIC SV *lt_tag(pTHX_ SV *value) {
 #endif /* !LT_HINT_STRUCT */
 
 #if LT_THREADSAFE
 #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));
 #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;
 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())) {
 
  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;
   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) {
 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);
  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) {
 STATIC U32 lt_initialized = 0;
 
 STATIC void lt_teardown(pTHX_ void *root) {
- dMY_CXT;
-
  if (!lt_initialized)
   return;
 
  if (!lt_initialized)
   return;
 
@@ -759,13 +755,16 @@ STATIC void lt_teardown(pTHX_ void *root) {
   return;
 #endif
 
   return;
 #endif
 
+ {
+  dMY_CXT;
 #if LT_THREADSAFE
 #if LT_THREADSAFE
- ptable_hints_free(MY_CXT.tbl);
 ptable_hints_free(MY_CXT.tbl);
 #endif
 #if !LT_HAS_RPEEP
 #endif
 #if !LT_HAS_RPEEP
- ptable_seen_free(MY_CXT.seen);
 ptable_seen_free(MY_CXT.seen);
 #endif
 #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;
 
  PL_check[OP_PADANY] = MEMBER_TO_FPTR(lt_old_ck_padany);
  lt_old_ck_padany    = 0;