Commit: 18cf235893d5d2163084afcd936713de273ece9e
Author: Campbell Barton
Date:   Mon May 11 12:39:08 2015 +1000
Branches: master
https://developer.blender.org/rB18cf235893d5d2163084afcd936713de273ece9e

GHash: use const keys when only used for lookups

===================================================================

M       source/blender/blenlib/BLI_ghash.h
M       source/blender/blenlib/intern/BLI_ghash.c

===================================================================

diff --git a/source/blender/blenlib/BLI_ghash.h 
b/source/blender/blenlib/BLI_ghash.h
index f5cc6c6..a9f8d9f 100644
--- a/source/blender/blenlib/BLI_ghash.h
+++ b/source/blender/blenlib/BLI_ghash.h
@@ -81,11 +81,11 @@ void  *BLI_ghash_lookup_default(GHash *gh, const void *key, 
void *val_default) A
 void **BLI_ghash_lookup_p(GHash *gh, const void *key) ATTR_WARN_UNUSED_RESULT;
 bool   BLI_ghash_ensure_p(GHash *gh, void *key, void ***r_val) 
ATTR_WARN_UNUSED_RESULT;
 bool   BLI_ghash_ensure_p_ex(GHash *gh, const void *key, void ***r_val, 
GHashKeyCopyFP keycopyfp) ATTR_WARN_UNUSED_RESULT;
-bool   BLI_ghash_remove(GHash *gh, void *key, GHashKeyFreeFP keyfreefp, 
GHashValFreeFP valfreefp);
+bool   BLI_ghash_remove(GHash *gh, const void *key, GHashKeyFreeFP keyfreefp, 
GHashValFreeFP valfreefp);
 void   BLI_ghash_clear(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP 
valfreefp);
 void   BLI_ghash_clear_ex(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP 
valfreefp,
                           const unsigned int nentries_reserve);
-void  *BLI_ghash_popkey(GHash *gh, void *key, GHashKeyFreeFP keyfreefp) 
ATTR_WARN_UNUSED_RESULT;
+void  *BLI_ghash_popkey(GHash *gh, const void *key, GHashKeyFreeFP keyfreefp) 
ATTR_WARN_UNUSED_RESULT;
 bool   BLI_ghash_haskey(GHash *gh, const void *key) ATTR_WARN_UNUSED_RESULT;
 unsigned int BLI_ghash_size(GHash *gh) ATTR_WARN_UNUSED_RESULT;
 void   BLI_ghash_flag_set(GHash *gh, unsigned int flag);
@@ -229,7 +229,7 @@ void   BLI_gset_insert(GSet *gh, void *key);
 bool   BLI_gset_add(GSet *gs, void *key);
 bool   BLI_gset_reinsert(GSet *gh, void *key, GSetKeyFreeFP keyfreefp);
 bool   BLI_gset_haskey(GSet *gs, const void *key) ATTR_WARN_UNUSED_RESULT;
-bool   BLI_gset_remove(GSet *gs, void *key, GSetKeyFreeFP keyfreefp);
+bool   BLI_gset_remove(GSet *gs, const void *key, GSetKeyFreeFP keyfreefp);
 void   BLI_gset_clear_ex(GSet *gs, GSetKeyFreeFP keyfreefp,
                          const unsigned int nentries_reserve);
 void   BLI_gset_clear(GSet *gs, GSetKeyFreeFP keyfreefp);
diff --git a/source/blender/blenlib/intern/BLI_ghash.c 
b/source/blender/blenlib/intern/BLI_ghash.c
index b0902fe..9287d62 100644
--- a/source/blender/blenlib/intern/BLI_ghash.c
+++ b/source/blender/blenlib/intern/BLI_ghash.c
@@ -535,7 +535,7 @@ BLI_INLINE bool ghash_insert_safe_keyonly(GHash *gh, void 
*key, const bool overr
  * Remove the entry and return it, caller must free from gh->entrypool.
  */
 static Entry *ghash_remove_ex(
-        GHash *gh, void *key, GHashKeyFreeFP keyfreefp, GHashValFreeFP 
valfreefp,
+        GHash *gh, const void *key, GHashKeyFreeFP keyfreefp, GHashValFreeFP 
valfreefp,
         const unsigned int bucket_index)
 {
        Entry *e_prev;
@@ -796,7 +796,7 @@ bool BLI_ghash_ensure_p_ex(
  * \param valfreefp  Optional callback to free the value.
  * \return true if \a key was removed from \a gh.
  */
-bool BLI_ghash_remove(GHash *gh, void *key, GHashKeyFreeFP keyfreefp, 
GHashValFreeFP valfreefp)
+bool BLI_ghash_remove(GHash *gh, const void *key, GHashKeyFreeFP keyfreefp, 
GHashValFreeFP valfreefp)
 {
        const unsigned int hash = ghash_keyhash(gh, key);
        const unsigned int bucket_index = ghash_bucket_index(gh, hash);
@@ -819,7 +819,7 @@ bool BLI_ghash_remove(GHash *gh, void *key, GHashKeyFreeFP 
keyfreefp, GHashValFr
  * \param keyfreefp  Optional callback to free the key.
  * \return the value of \a key int \a gh or NULL.
  */
-void *BLI_ghash_popkey(GHash *gh, void *key, GHashKeyFreeFP keyfreefp)
+void *BLI_ghash_popkey(GHash *gh, const void *key, GHashKeyFreeFP keyfreefp)
 {
        const unsigned int hash = ghash_keyhash(gh, key);
        const unsigned int bucket_index = ghash_bucket_index(gh, hash);
@@ -1303,7 +1303,7 @@ bool BLI_gset_reinsert(GSet *gs, void *key, GSetKeyFreeFP 
keyfreefp)
        return ghash_insert_safe_keyonly((GHash *)gs, key, true, keyfreefp);
 }
 
-bool BLI_gset_remove(GSet *gs, void *key, GSetKeyFreeFP keyfreefp)
+bool BLI_gset_remove(GSet *gs, const void *key, GSetKeyFreeFP keyfreefp)
 {
        return BLI_ghash_remove((GHash *)gs, key, keyfreefp, NULL);
 }

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to