Only declare dMY_CXT when really needed
authorVincent Pit <vince@profvince.com>
Mon, 3 Jan 2011 21:45:38 +0000 (22:45 +0100)
committerVincent Pit <vince@profvince.com>
Mon, 3 Jan 2011 21:45:38 +0000 (22:45 +0100)
indirect.xs

index 49bdd20..f7b22d3 100644 (file)
@@ -330,7 +330,6 @@ STATIC SV *indirect_tag(pTHX_ SV *value) {
 #define indirect_tag(V) indirect_tag(aTHX_ (V))
  indirect_hint_t *h;
  SV *code = NULL;
- dMY_CXT;
 
  if (SvROK(value)) {
   value = SvRV(value);
@@ -351,10 +350,13 @@ STATIC SV *indirect_tag(pTHX_ SV *value) {
 #endif /* !I_HINT_STRUCT */
 
 #if I_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 /* I_THREADSAFE */
 
  return newSViv(PTR2IV(h));
@@ -363,14 +365,16 @@ STATIC SV *indirect_tag(pTHX_ SV *value) {
 STATIC SV *indirect_detag(pTHX_ const SV *hint) {
 #define indirect_detag(H) indirect_detag(aTHX_ (H))
  indirect_hint_t *h;
- dMY_CXT;
 
  if (!(hint && SvIOK(hint)))
   return NULL;
 
  h = INT2PTR(indirect_hint_t *, SvIVX(hint));
 #if I_THREADSAFE
- h = ptable_fetch(MY_CXT.tbl, h);
+ {
+  dMY_CXT;
+  h = ptable_fetch(MY_CXT.tbl, h);
+ }
 #endif /* I_THREADSAFE */
 
 #if I_WORKAROUND_REQUIRE_PROPAGATION
@@ -790,8 +794,6 @@ done:
 STATIC U32 indirect_initialized = 0;
 
 STATIC void indirect_teardown(pTHX_ void *root) {
- dMY_CXT;
-
  if (!indirect_initialized)
   return;
 
@@ -800,10 +802,13 @@ STATIC void indirect_teardown(pTHX_ void *root) {
   return;
 #endif
 
- ptable_free(MY_CXT.map);
+ {
+  dMY_CXT;
+  ptable_free(MY_CXT.map);
 #if I_THREADSAFE
- ptable_hints_free(MY_CXT.tbl);
 ptable_hints_free(MY_CXT.tbl);
 #endif
+ }
 
  PL_check[OP_CONST]           = MEMBER_TO_FPTR(indirect_old_ck_const);
  indirect_old_ck_const        = 0;