]> git.vpit.fr Git - perl/modules/indirect.git/commitdiff
Don't actually create an entry when storing NULL in the ptable
authorVincent Pit <vince@profvince.com>
Fri, 29 May 2009 09:52:20 +0000 (11:52 +0200)
committerVincent Pit <vince@profvince.com>
Fri, 29 May 2009 09:52:20 +0000 (11:52 +0200)
This is actually unneeded because ptable_fetch() returns NULL when it can't find the entry. This way we can remove the short-lived ptable_delete().

indirect.xs
ptable.h

index f318932cc8adc8bfa3d7a07e2315813ceb1660e1..12256c3544ea418e84420c9f4a12df471379c688 100644 (file)
@@ -163,7 +163,6 @@ typedef struct {
 #include "ptable.h"
 
 #define ptable_store(T, K, V) ptable_store(aTHX_ (T), (K), (V))
-#define ptable_delete(T, K)   ptable_delete(aTHX_ (T), (K))
 #define ptable_clear(T)       ptable_clear(aTHX_ (T))
 #define ptable_free(T)        ptable_free(aTHX_ (T))
 
@@ -392,7 +391,7 @@ STATIC void indirect_map_delete(pTHX_ const OP *o) {
 #define indirect_map_delete(O) indirect_map_delete(aTHX_ (O))
  dMY_CXT;
 
- ptable_delete(MY_CXT.map, o);
+ ptable_store(MY_CXT.map, o, NULL);
 }
 
 /* --- Check functions ----------------------------------------------------- */
index ba275bac8c717523f844034a31336d817820aaaa..f3d2712e6b4e6d1d4e32a474e82fa6290db0e246 100644 (file)
--- a/ptable.h
+++ b/ptable.h
@@ -117,16 +117,6 @@ STATIC void *ptable_fetch(const ptable * const t, const void * const key) {
 }
 #endif /* !ptable_fetch */
 
-STATIC void PTABLE_PREFIX(_delete)(pPTBL_ const ptable * const t, const void * const key) {
- ptable_ent *const ent = ptable_find(t, key);
-
- if (ent) {
-  void *val = ent->val;
-  PTABLE_VAL_FREE(val);
-  ent->val = NULL;
- }
-}
-
 #ifndef ptable_split
 STATIC void ptable_split(pPTBLMS_ ptable * const t) {
 #define ptable_split(T) ptable_split(aPTBLMS_ (T))
@@ -165,7 +155,7 @@ STATIC void PTABLE_PREFIX(_store)(pPTBL_ ptable * const t, const void * const ke
   void *oldval = ent->val;
   PTABLE_VAL_FREE(oldval);
   ent->val = val;
- } else {
+ } else if (val) {
   const UV i = PTABLE_HASH(key) & t->max;
   ent = PerlMemShared_malloc(sizeof *ent);
   ent->key  = key;