]> git.vpit.fr Git - perl/modules/indirect.git/blobdiff - indirect.xs
Use the hint pointer as the unique identifier for the %^H entry
[perl/modules/indirect.git] / indirect.xs
index 8e6c789b1b0098315650bf8b05193aac0eb0c77e..00622a5c10f5b2d5b3488ed2ca40f8b600dfdffe 100644 (file)
@@ -267,7 +267,7 @@ STATIC SV *indirect_tag(pTHX_ SV *value) {
  SV *code = NULL;
  dMY_CXT;
 
- if (SvOK(value) && SvROK(value)) {
+ if (SvROK(value)) {
   value = SvRV(value);
   if (SvTYPE(value) >= SVt_PVCV) {
    code = value;
@@ -302,10 +302,10 @@ STATIC SV *indirect_tag(pTHX_ SV *value) {
 
  /* 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 value pointer as the key itself. */
- ptable_hints_store(MY_CXT.tbl, value, h);
+  * use the hint as the key itself. */
+ ptable_hints_store(MY_CXT.tbl, h, h);
 
- return newSVuv(PTR2UV(value));
+ return newSViv(PTR2IV(h));
 }
 
 STATIC SV *indirect_detag(pTHX_ const SV *hint) {
@@ -313,10 +313,10 @@ STATIC SV *indirect_detag(pTHX_ const SV *hint) {
  indirect_hint_t *h;
  dMY_CXT;
 
- if (!(hint && SvOK(hint) && SvIOK(hint)))
+ if (!(hint && SvIOK(hint)))
   return NULL;
 
- h = ptable_fetch(MY_CXT.tbl, INT2PTR(void *, SvUVX(hint)));
+ h = ptable_fetch(MY_CXT.tbl, INT2PTR(void *, SvIVX(hint)));
 
 #if I_WORKAROUND_REQUIRE_PROPAGATION
  {
@@ -346,16 +346,16 @@ STATIC SV *indirect_tag(pTHX_ SV *value) {
 #define indirect_tag(V) indirect_tag(aTHX_ (V))
  UV tag = 0;
 
- if (SvOK(value) && SvROK(value)) {
+ if (SvROK(value)) {
   value = SvRV(value);
-  SvREFCNT_inc(value);
-  tag = PTR2UV(value);
+  SvREFCNT_inc_simple_NN(value);
+  tag = PTR2IV(value);
  }
 
- return newSVuv(tag);
+ return newSViv(tag);
 }
 
-#define indirect_detag(H) (((H) && SvOK(H)) ? INT2PTR(SV *, SvUVX(H)) : NULL)
+#define indirect_detag(H) (((H) && SvIOK(H)) ? INT2PTR(SV *, SvIVX(H)) : NULL)
 
 #endif /* I_THREADSAFE || I_WORKAROUND_REQUIRE_PROPAGATION */