Code cleanup: simplify standard GHash creation.
authorNicholas Bishop <nicholasbishop@gmail.com>
Wed, 16 May 2012 00:51:36 +0000 (00:51 +0000)
committerNicholas Bishop <nicholasbishop@gmail.com>
Wed, 16 May 2012 00:51:36 +0000 (00:51 +0000)
Added four new functions as shortcuts to creating GHashes that use the
standard ptr/str/int/pair hash and compare functions.

GHash *BLI_ghash_ptr_new(const char *info);
GHash *BLI_ghash_str_new(const char *info);
GHash *BLI_ghash_int_new(const char *info);
GHash *BLI_ghash_pair_new(const char *info);

Replaced almost all occurrences of BLI_ghash_new() with one of the
above functions.

42 files changed:
source/blender/blenkernel/intern/action.c
source/blender/blenkernel/intern/depsgraph.c
source/blender/blenkernel/intern/icons.c
source/blender/blenkernel/intern/nla.c
source/blender/blenkernel/intern/softbody.c
source/blender/blenkernel/intern/tracking.c
source/blender/blenlib/BLI_ghash.h
source/blender/blenlib/intern/BLI_ghash.c
source/blender/blenlib/intern/pbvh.c
source/blender/blenloader/intern/readblenentry.c
source/blender/bmesh/intern/bmesh_core.c
source/blender/bmesh/intern/bmesh_mesh.c
source/blender/bmesh/intern/bmesh_operators.c
source/blender/bmesh/intern/bmesh_walkers.c
source/blender/bmesh/intern/bmesh_walkers_impl.c
source/blender/bmesh/operators/bmo_create.c
source/blender/bmesh/operators/bmo_dupe.c
source/blender/bmesh/operators/bmo_hull.c
source/blender/bmesh/tools/BME_bevel.c
source/blender/editors/animation/anim_filter.c
source/blender/editors/armature/editarmature.c
source/blender/editors/armature/editarmature_retarget.c
source/blender/editors/armature/editarmature_sketch.c
source/blender/editors/armature/reeb.c
source/blender/editors/curve/editcurve.c
source/blender/editors/interface/interface_ops.c
source/blender/editors/mesh/editmesh_knife.c
source/blender/editors/mesh/editmesh_tools.c
source/blender/editors/object/object_add.c
source/blender/editors/sculpt_paint/paint_vertex.c
source/blender/gpu/intern/gpu_codegen.c
source/blender/makesdna/intern/dna_genfile.c
source/blender/makesrna/intern/rna_access.c
source/blender/modifiers/intern/MOD_boolean_util.c
source/blender/modifiers/intern/MOD_build.c
source/blender/modifiers/intern/MOD_mask.c
source/blender/python/intern/bpy_rna.c
source/blender/render/intern/source/convertblender.c
source/blender/render/intern/source/sss.c
source/blender/render/intern/source/strand.c
source/blender/windowmanager/intern/wm.c
source/blender/windowmanager/intern/wm_operators.c

index 9e46d03a3ab694674392372df4f83c7025688030..0f8716e2b04f0401dedfa274a3c6f91a7bc87b38 100644 (file)
@@ -574,7 +574,7 @@ void BKE_pose_channels_hash_make(bPose *pose)
        if (!pose->chanhash) {
                bPoseChannel *pchan;
 
-               pose->chanhash = BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp, "make_pose_chan gh");
+               pose->chanhash = BLI_ghash_str_new("make_pose_chan gh");
                for (pchan = pose->chanbase.first; pchan; pchan = pchan->next)
                        BLI_ghash_insert(pose->chanhash, pchan->name, pchan);
        }
index c6f46a7309bfd79c14a5c7a71e364df25f96869e..31d2ef9175b1ab98ede8abbf4e18f54e66ec9db8 100644 (file)
@@ -867,7 +867,7 @@ DagNode *dag_add_node(DagForest *forest, void *fob)
                }
 
                if (!forest->nodeHash)
-                       forest->nodeHash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "dag_add_node gh");
+                       forest->nodeHash = BLI_ghash_ptr_new("dag_add_node gh");
                BLI_ghash_insert(forest->nodeHash, fob, node);
        }
 
index 5990e92798e3229be1078cb62aa87bbc08ecff1c..8a49cba7649361d33e54312a5a48d8ff39855efa 100644 (file)
@@ -103,7 +103,7 @@ void BKE_icons_init(int first_dyn_id)
        gFirstIconId = first_dyn_id;
 
        if (!gIcons)
-               gIcons = BLI_ghash_new(BLI_ghashutil_inthash, BLI_ghashutil_intcmp, "icons_init gh");
+               gIcons = BLI_ghash_int_new("icons_init gh");
 }
 
 void BKE_icons_free(void)
index 02d44badc6572fa5b8be83d56089e92caec266a2..2b4fe72e8bb4496a423795af6d22d61b46873fcc 100644 (file)
@@ -1304,7 +1304,7 @@ void BKE_nlastrip_validate_name(AnimData *adt, NlaStrip *strip)
         *      - this is easier than iterating over all the tracks+strips hierarchy everytime
         *        (and probably faster)
         */
-       gh = BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp, "nlastrip_validate_name gh");
+       gh = BLI_ghash_str_new("nlastrip_validate_name gh");
        
        for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) {
                for (tstrip = nlt->strips.first; tstrip; tstrip = tstrip->next) {
index ee70d4228deac5852873c55d50b38999f576c26c..a66b8a1a373456ba937ddd56a6fad3ff991e3b32 100644 (file)
@@ -3669,7 +3669,7 @@ static void sb_new_scratch(SoftBody *sb)
 {
        if (!sb) return;
        sb->scratch = MEM_callocN(sizeof(SBScratch), "SBScratch");
-       sb->scratch->colliderhash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "sb_new_scratch gh");
+       sb->scratch->colliderhash = BLI_ghash_ptr_new("sb_new_scratch gh");
        sb->scratch->bodyface = NULL;
        sb->scratch->totface = 0;
        sb->scratch->aabbmax[0]=sb->scratch->aabbmax[1]=sb->scratch->aabbmax[2] = 1.0e30f;
index 4e2b4be474bf69544076758f379ce630e37fc923..8339e973d43918e1317d32461f9ad03ca70707a7 100644 (file)
@@ -768,7 +768,7 @@ static TracksMap *tracks_map_new(const char *object_name, int is_camera, int num
        if (customdata_size)
                map->customdata = MEM_callocN(customdata_size*num_tracks, "TracksMap customdata");
 
-       map->hash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "TracksMap hash");
+       map->hash = BLI_ghash_ptr_new("TracksMap hash");
 
        return map;
 }
index b2532d0e4860d3cf57d6e895d4cc600182e0fba4..9034e8e51d982b0ee0bcd97da146c70d0d8287c4 100644 (file)
@@ -147,6 +147,11 @@ int             BLI_ghashutil_strcmp(const void *a, const void *b);
 unsigned int    BLI_ghashutil_inthash(const void *ptr);
 int             BLI_ghashutil_intcmp(const void *a, const void *b);
 
+GHash          *BLI_ghash_ptr_new(const char *info);
+GHash          *BLI_ghash_str_new(const char *info);
+GHash          *BLI_ghash_int_new(const char *info);
+GHash          *BLI_ghash_pair_new(const char *info);
+
 typedef struct GHashPair {
        const void *first;
        const void *second;
index 6ec3d0336720ac3eda19eac5dc37876990a59349..5cfde3dfb777b8fd632c897065b6cf263b12fe88 100644 (file)
@@ -305,6 +305,23 @@ int BLI_ghashutil_strcmp(const void *a, const void *b)
        return strcmp(a, b);
 }
 
+GHash *BLI_ghash_ptr_new(const char *info)
+{
+       return BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, info);
+}
+GHash *BLI_ghash_str_new(const char *info)
+{
+       return BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp, info);
+}
+GHash *BLI_ghash_int_new(const char *info)
+{
+       return BLI_ghash_new(BLI_ghashutil_inthash, BLI_ghashutil_intcmp, info);
+}
+GHash *BLI_ghash_pair_new(const char *info)
+{
+       return BLI_ghash_new(BLI_ghashutil_pairhash, BLI_ghashutil_paircmp, info);
+}
+
 GHashPair *BLI_ghashutil_pairalloc(const void *first, const void *second)
 {
        GHashPair *pair = MEM_mallocN(sizeof(GHashPair), "GHashPair");
index 73a90fa53a03dc32a9bb740eb19a48b33d914978..fdb0cc0ccc8fbcd078ff86e4fee291d83977a15f 100644 (file)
@@ -381,7 +381,7 @@ static void build_mesh_leaf_node(PBVH *bvh, PBVHNode *node)
        GHash *map;
        int i, j, totface;
 
-       map = BLI_ghash_new(BLI_ghashutil_inthash, BLI_ghashutil_intcmp, "build_mesh_leaf_node gh");
+       map = BLI_ghash_int_new("build_mesh_leaf_node gh");
        
        node->uniq_verts = node->face_verts = 0;
        totface = node->totprim;
@@ -1262,7 +1262,7 @@ void BLI_pbvh_get_grid_updates(PBVH *bvh, int clear, void ***gridfaces, int *tot
        unsigned i;
        int tot;
 
-       map = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "pbvh_get_grid_updates gh");
+       map = BLI_ghash_ptr_new("pbvh_get_grid_updates gh");
 
        pbvh_iter_begin(&iter, bvh, NULL, NULL);
 
index 4abbcb1888cb34b9ec25e5f1d6fd10f10335e07c..eb12a7bd837d2eff0c4fda2ab3a891434fdbae7c 100644 (file)
@@ -221,7 +221,7 @@ LinkNode *BLO_blendhandle_get_previews(BlendHandle *bh, int ofblocktype, int *to
 LinkNode *BLO_blendhandle_get_linkable_groups(BlendHandle *bh) 
 {
        FileData *fd = (FileData *) bh;
-       GHash *gathered = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "linkable_groups gh");
+       GHash *gathered = BLI_ghash_ptr_new("linkable_groups gh");
        LinkNode *names = NULL;
        BHead *bhead;
        
index e20eb103e1b09a8ed222e28c46478449443cd492..736a43e16761b93da325a7c4546f43d3a8475891 100644 (file)
@@ -1833,7 +1833,7 @@ int bmesh_vert_separate(BMesh *bm, BMVert *v, BMVert ***r_vout, int *r_vout_len)
        int i, maxindex;
        BMLoop *nl;
 
-       visithash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, __func__);
+       visithash = BLI_ghash_ptr_new(__func__);
 
        maxindex = 0;
        BM_ITER_ELEM (e, &eiter, v, BM_EDGES_OF_VERT) {
index fe94983dc88d72de6e24da63d9ab5f788508d546..8d9f2ed7336d833f006fe0bda90cd6118055259e 100644 (file)
@@ -624,7 +624,7 @@ void BM_mesh_remap(BMesh *bm, int *vert_idx, int *edge_idx, int *face_idx)
                int *new_idx = NULL;
 
                /* Init the old-to-new vert pointers mapping */
-               vptr_map = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "BM_mesh_remap vert pointers mapping");
+               vptr_map = BLI_ghash_ptr_new("BM_mesh_remap vert pointers mapping");
 
                /* Make a copy of all vertices. */
                verts_pool = MEM_callocN(sizeof(BMVert *) * totvert, "BM_mesh_remap verts pool");
@@ -658,7 +658,7 @@ void BM_mesh_remap(BMesh *bm, int *vert_idx, int *edge_idx, int *face_idx)
                int *new_idx = NULL;
 
                /* Init the old-to-new vert pointers mapping */
-               eptr_map = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "BM_mesh_remap edge pointers mapping");
+               eptr_map = BLI_ghash_ptr_new("BM_mesh_remap edge pointers mapping");
 
                /* Make a copy of all vertices. */
                edges_pool = MEM_callocN(sizeof(BMEdge *) * totedge, "BM_mesh_remap edges pool");
@@ -691,7 +691,7 @@ void BM_mesh_remap(BMesh *bm, int *vert_idx, int *edge_idx, int *face_idx)
                int *new_idx = NULL;
 
                /* Init the old-to-new vert pointers mapping */
-               fptr_map = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "BM_mesh_remap face pointers mapping");
+               fptr_map = BLI_ghash_ptr_new("BM_mesh_remap face pointers mapping");
 
                /* Make a copy of all vertices. */
                faces_pool = MEM_callocN(sizeof(BMFace *) * totface, "BM_mesh_remap faces pool");
index 97347f841c8a7ea0e53466d3f5f8f4d12192343c..b2d9590dc5433fba63e6c9b113e82288d5f7c84e 100644 (file)
@@ -274,7 +274,7 @@ void BMO_slot_copy(BMOperator *source_op, BMOperator *dest_op, const char *src,
                }
 
                if (!dest_slot->data.ghash) {
-                       dest_slot->data.ghash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "bmesh operator 2");
+                       dest_slot->data.ghash = BLI_ghash_ptr_new("bmesh operator 2");
                }
 
                BLI_ghashIterator_init(&it, source_slot->data.ghash);
@@ -556,7 +556,7 @@ void BMO_slot_map_insert(BMesh *UNUSED(bm), BMOperator *op, const char *slotname
        memcpy(mapping + 1, data, len);
 
        if (!slot->data.ghash) {
-               slot->data.ghash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "bmesh slot map hash");
+               slot->data.ghash = BLI_ghash_ptr_new("bmesh slot map hash");
        }
 
        BLI_ghash_insert(slot->data.ghash, element, mapping);
index ea29c149c1af3c1dc6bc0afe8566dd2d39badf53..79e097a7a7c583993c6be98132835d6113bc59de 100644 (file)
@@ -87,8 +87,8 @@ void BMW_init(BMWalker *walker, BMesh *bm, int type,
        walker->mask_edge = mask_edge;
        walker->mask_face = mask_face;
 
-       walker->visithash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "bmesh walkers 1");
-       walker->secvisithash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "bmesh walkers sec 1");
+       walker->visithash = BLI_ghash_ptr_new("bmesh walkers 1");
+       walker->secvisithash = BLI_ghash_ptr_new("bmesh walkers sec 1");
 
        if (UNLIKELY(type >= BMW_MAXWALKERS || type < 0)) {
                fprintf(stderr,
@@ -254,6 +254,6 @@ void BMW_reset(BMWalker *walker)
        walker->depth = 0;
        BLI_ghash_free(walker->visithash, NULL, NULL);
        BLI_ghash_free(walker->secvisithash, NULL, NULL);
-       walker->visithash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "bmesh walkers 1");
-       walker->secvisithash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "bmesh walkers sec 1");
+       walker->visithash = BLI_ghash_ptr_new("bmesh walkers 1");
+       walker->secvisithash = BLI_ghash_ptr_new("bmesh walkers sec 1");
 }
index 01c269657dce19a9bea894929e3929d7afb7424a..4ae7b6cc3506784c47661362effa9b8d36974fc3 100644 (file)
@@ -482,7 +482,7 @@ static void bmw_LoopWalker_begin(BMWalker *walker, void *data)
        lwalk->lastv = lwalk->startv = BM_edge_other_vert(owalk.cur, lwalk->lastv);
 
        BLI_ghash_free(walker->visithash, NULL, NULL);
-       walker->visithash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "bmesh walkers 2");
+       walker->visithash = BLI_ghash_ptr_new("bmesh walkers 2");
        BLI_ghash_insert(walker->visithash, owalk.cur, NULL);
 }
 
@@ -707,11 +707,11 @@ static void bmw_FaceLoopWalker_begin(BMWalker *walker, void *data)
        lwalk->nocalc = 0;
 
        BLI_ghash_free(walker->secvisithash, NULL, NULL);
-       walker->secvisithash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "bmesh walkers 3");
+       walker->secvisithash = BLI_ghash_ptr_new("bmesh walkers 3");
        BLI_ghash_insert(walker->visithash, lwalk->l->e, NULL);
 
        BLI_ghash_free(walker->visithash, NULL, NULL);
-       walker->visithash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "bmesh walkers 3");
+       walker->visithash = BLI_ghash_ptr_new("bmesh walkers 3");
        BLI_ghash_insert(walker->visithash, lwalk->l->f, NULL);
 }
 
@@ -814,7 +814,7 @@ static void bmw_EdgeringWalker_begin(BMWalker *walker, void *data)
        }
 
        BLI_ghash_free(walker->visithash, NULL, NULL);
-       walker->visithash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "bmesh walkers 4");
+       walker->visithash = BLI_ghash_ptr_new("bmesh walkers 4");
        BLI_ghash_insert(walker->visithash, lwalk->l->e, NULL);
 }
 
index 85aed6141bbd89de24faddc24d0eaac0e81ca2a3..7ef6068247d2d8c057ef62d8eb72a1292e811381 100644 (file)
@@ -733,7 +733,7 @@ static EPath *edge_find_shortest_path(BMesh *bm, BMOperator *op, BMEdge *edge, E
                                       VertData *vdata, PathBase *pathbase, int group)
 {
        BMEdge *e;
-       GHash *gh = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "createops find shortest path");
+       GHash *gh = BLI_ghash_ptr_new("createops find shortest path");
        BMVert *v1, *v2;
        BMVert **verts = NULL;
        BLI_array_staticdeclare(verts, 1024);
index 212ec33e626a3cefa928fa3e7ddf41b03cd79d6d..ae001b2baf62c8b32c17023478ce2f7515724ed2 100644 (file)
@@ -197,8 +197,8 @@ static void BKE_mesh_copy(BMOperator *op, BMesh *source, BMesh *target)
        GHash *vhash, *ehash;
 
        /* initialize pointer hashes */
-       vhash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "bmesh dupeops v");
-       ehash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "bmesh dupeops e");
+       vhash = BLI_ghash_ptr_new("bmesh dupeops v");
+       ehash = BLI_ghash_ptr_new("bmesh dupeops e");
 
        /* duplicate flagged vertices */
        BM_ITER_MESH (v, &viter, source, BM_VERTS_OF_MESH) {
index 20d0160311df99c9eb0c8548d52b391f833362fd..2a48a531566ab74795df53321f9f7e906ead0e7d 100644 (file)
@@ -154,9 +154,7 @@ static GHash *hull_triangles_v_outside(GHash *hull_triangles, const BMVert *v)
        GHash *outside;
        GHashIterator iter;
 
-       outside = BLI_ghash_new(BLI_ghashutil_ptrhash,
-                               BLI_ghashutil_ptrcmp,
-                               "outside");
+       outside = BLI_ghash_ptr_new("outside");
 
        GHASH_ITER (iter, hull_triangles) {
                HullTriangle *t = BLI_ghashIterator_getKey(&iter);
@@ -298,9 +296,7 @@ static HullFinalEdges *hull_final_edges(GHash *hull_triangles)
        GHashIterator iter;
        
        final_edges = MEM_callocN(sizeof(HullFinalEdges), "HullFinalEdges");
-       final_edges->edges = BLI_ghash_new(BLI_ghashutil_ptrhash,
-                                          BLI_ghashutil_ptrcmp,
-                                          "final edges ghash");
+       final_edges->edges = BLI_ghash_ptr_new("final edges ghash");
        final_edges->base_pool = BLI_mempool_create(sizeof(ListBase), 128, 128, 0);
        final_edges->link_pool = BLI_mempool_create(sizeof(LinkData), 128, 128, 0);
 
@@ -683,9 +679,7 @@ void bmo_convex_hull_exec(BMesh *bm, BMOperator *op)
 
        edge_pool = BLI_mempool_create(sizeof(HullBoundaryEdge), 128, 128, 0);
        hull_pool = BLI_mempool_create(sizeof(HullTriangle), 128, 128, 0);
-       hull_triangles = BLI_ghash_new(BLI_ghashutil_ptrhash,
-                                      BLI_ghashutil_ptrcmp,
-                                      "hull_triangles");
+       hull_triangles = BLI_ghash_ptr_new("hull_triangles");
 
        /* Add tetrahedron triangles */
        hull_add_tetrahedron(bm, hull_triangles, hull_pool, tetra);
index df031a50d54613d2ae22345679d4f7dd6de58e67..101614d609c148cdb84b57f98b0661ae8c55670d 100644 (file)
@@ -72,7 +72,7 @@ BME_TransData_Head *BME_init_transdata(int bufsize)
        BME_TransData_Head *td;
 
        td = MEM_callocN(sizeof(BME_TransData_Head), "BM transdata header");
-       td->gh = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "BME_init_transdata gh");
+       td->gh = BLI_ghash_ptr_new("BME_init_transdata gh");
        td->ma = BLI_memarena_new(bufsize, "BME_TransData arena");
        BLI_memarena_use_calloc(td->ma);
 
index 2729396cb4ae0f1453dc645e2f4fb73d173608d4..fcf424e34dc5230c3e3a408be66774490f415a16 100644 (file)
@@ -2223,7 +2223,7 @@ static size_t animdata_filter_remove_duplis(ListBase *anim_data)
        /* build new hashtable to efficiently store and retrieve which entries have been 
         * encountered already while searching
         */
-       gh = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "animdata_filter_duplis_remove gh");
+       gh = BLI_ghash_ptr_new("animdata_filter_duplis_remove gh");
        
        /* loop through items, removing them from the list if a similar item occurs already */
        for (ale = anim_data->first; ale; ale = next) {
index 8e2dfb727033f2c776ff500ecada229fb99d68f6..7ce2988b067b2d55445fa6da42d09fe9d2abc386 100644 (file)
@@ -5945,7 +5945,7 @@ void generateSkeletonFromReebGraph(Scene *scene, ReebGraph *rg)
        
        ED_armature_to_edit(obedit);
 
-       arcBoneMap = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "SkeletonFromReebGraph gh");
+       arcBoneMap = BLI_ghash_ptr_new("SkeletonFromReebGraph gh");
        
        BLI_markdownSymmetry((BGraph *)rg, rg->nodes.first, scene->toolsettings->skgen_symmetry_limit);
        
index 566dbc901b8b117d1dd61066a59040249758c448..80f8c61694c2af8b673f1fca072a29b9b2c53ace 100644 (file)
@@ -298,8 +298,8 @@ static RigGraph *newRigGraph(void)
        
        rg->head = NULL;
        
-       rg->bones_map = BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp, "newRigGraph bones gh");
-       rg->controls_map = BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp, "newRigGraph cont gh");
+       rg->bones_map = BLI_ghash_str_new("newRigGraph bones gh");
+       rg->controls_map = BLI_ghash_str_new("newRigGraph cont gh");
        
        rg->free_arc = RIG_freeRigArc;
        rg->free_node = NULL;
@@ -532,7 +532,7 @@ static RigGraph *cloneRigGraph(RigGraph *src, ListBase *editbones, Object *ob, c
        RigControl *ctrl;
        RigGraph *rg;
        
-       ptr_hash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "cloneRigGraph gh");
+       ptr_hash = BLI_ghash_ptr_new("cloneRigGraph gh");
 
        rg = newRigGraph();
        
index 2201bcf7224dd3fe104ebbf90d5606d9f1a8b59d..06ecf76ba3e1ac704e21afbabae17726d5893bab 100644 (file)
@@ -165,7 +165,7 @@ void BIF_makeListTemplates(const bContext *C)
                BLI_ghash_free(TEMPLATES_HASH, NULL, NULL);
        }
 
-       TEMPLATES_HASH = BLI_ghash_new(BLI_ghashutil_inthash, BLI_ghashutil_intcmp, "makeListTemplates gh");
+       TEMPLATES_HASH = BLI_ghash_int_new("makeListTemplates gh");
        TEMPLATES_CURRENT = 0;
 
        for (base = FIRSTBASE; base; base = base->next) {
index 2564683ddd2956c667ef75f2e68e1d0708dbc713..316c4699c0b3abc4d1ba60484491933fe9f58466 100644 (file)
@@ -354,7 +354,7 @@ static ReebArc *copyArc(ReebGraph *rg, ReebArc *arc)
        memcpy(cp_arc->buckets, arc->buckets, sizeof(EmbedBucket) * cp_arc->bcount);
        
        /* copy faces map */
-       cp_arc->faces = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "copyArc gh");
+       cp_arc->faces = BLI_ghash_ptr_new("copyArc gh");
        mergeArcFaces(rg, cp_arc, arc);
        
        /* find corresponding head and tail */
@@ -2295,7 +2295,7 @@ static ReebEdge *createArc(ReebGraph *rg, ReebNode *node1, ReebNode *node2)
                
                arc->flag = 0; // clear flag on init
                arc->symmetry_level = 0;
-               arc->faces = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "createArc gh");
+               arc->faces = BLI_ghash_ptr_new("createArc gh");
                
                if (node1->weight <= node2->weight) {
                        v1 = node1;     
index e2824ee35cc1fe7544190a859db3e432e03f84b2..7afba0492327f1275ccfc16eaec64402c720d20b 100644 (file)
@@ -311,7 +311,7 @@ static void init_editNurb_keyIndex(EditNurb *editnurb, ListBase *origBase)
 
        if (editnurb->keyindex) return;
 
-       gh = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "editNurb keyIndex");
+       gh = BLI_ghash_ptr_new("editNurb keyIndex");
 
        while (orignu) {
                if (orignu->bezt) {
@@ -667,7 +667,7 @@ static GHash *dupli_keyIndexHash(GHash *keyindex)
        GHash *gh;
        GHashIterator *hashIter;
 
-       gh = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "dupli_keyIndex gh");
+       gh = BLI_ghash_ptr_new("dupli_keyIndex gh");
 
        for (hashIter = BLI_ghashIterator_new(keyindex);
             !BLI_ghashIterator_isDone(hashIter);
index 6d2ac388374b4bb3e4aa45275f9101eabe78a29b..f2a43580fd87a7b010b65496e8367fb0c0128520 100644 (file)
@@ -589,9 +589,7 @@ static void ui_editsource_active_but_set(uiBut *but)
        ui_editsource_info = MEM_callocN(sizeof(uiEditSourceStore), __func__);
        memcpy(&ui_editsource_info->but_orig, but, sizeof(uiBut));
 
-       ui_editsource_info->hash = BLI_ghash_new(BLI_ghashutil_ptrhash,
-                                                BLI_ghashutil_ptrcmp,
-                                                __func__);
+       ui_editsource_info->hash = BLI_ghash_ptr_new(__func__);
 }
 
 static void ui_editsource_active_but_clear(void)
index d49b77c7005e24a88a9dd54991fe8e55f541edd1..a9ec893adb7a058b8c443f7cafec6647253f3f7f 100644 (file)
@@ -2829,9 +2829,9 @@ static int knifetool_init(bContext *C, wmOperator *op, int UNUSED(do_cut))
        kcd->kverts = BLI_mempool_create(sizeof(KnifeVert), 1, 512, BLI_MEMPOOL_ALLOW_ITER);
        kcd->kedges = BLI_mempool_create(sizeof(KnifeEdge), 1, 512, BLI_MEMPOOL_ALLOW_ITER);
 
-       kcd->origedgemap = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "knife origedgemap");
-       kcd->origvertmap = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "knife origvertmap");
-       kcd->kedgefacemap = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "knife origvertmap");
+       kcd->origedgemap = BLI_ghash_ptr_new("knife origedgemap");
+       kcd->origvertmap = BLI_ghash_ptr_new("knife origvertmap");
+       kcd->kedgefacemap = BLI_ghash_ptr_new("knife origvertmap");
 
        /* cut all the way through the mesh if use_occlude_geometry button not pushed */
        kcd->cut_through = !RNA_boolean_get(op->ptr, "use_occlude_geometry");
index 9be71218da0d0be3e2aa2417f7ded325044a7eef..7f746ed9ef5faa6816516631fd9d1af21e01cc1a 100644 (file)
@@ -2700,7 +2700,7 @@ static int edbm_knife_cut_exec(bContext *C, wmOperator *op)
        }
 
        /* the floating point coordinates of verts in screen space will be stored in a hash table according to the vertices pointer */
-       gh = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "knife cut exec");
+       gh = BLI_ghash_ptr_new("knife cut exec");
        for (bv = BM_iter_new(&iter, bm, BM_VERTS_OF_MESH, NULL); bv; bv = BM_iter_step(&iter)) {
                scr = MEM_mallocN(sizeof(float) * 2, "Vertex Screen Coordinates");
                copy_v3_v3(co, bv->co);
index 466338a736f61ddd73186da6670fcaebd7c0fd9e..69aae5c4f060abee7d2e31ab558410dd3df2ad3d 100644 (file)
@@ -1067,8 +1067,8 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base,
        lb = object_duplilist(scene, base->object);
 
        if (use_hierarchy || use_base_parent) {
-               dupli_gh = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "make_object_duplilist_real dupli_gh");
-               parent_gh = BLI_ghash_new(BLI_ghashutil_pairhash, BLI_ghashutil_paircmp, "make_object_duplilist_real parent_gh");
+               dupli_gh = BLI_ghash_ptr_new("make_object_duplilist_real dupli_gh");
+               parent_gh = BLI_ghash_pair_new("make_object_duplilist_real parent_gh");
        }
        
        for (dob = lb->first; dob; dob = dob->next) {
index 3b74ae54810d1a02a4802d5448fe547fdb96724c..d544183ced83a0b1a33d11403dc1473614c0e241 100644 (file)
@@ -2079,7 +2079,7 @@ static char *wpaint_make_validmap(Object *ob)
                return NULL;
        }
 
-       gh = BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp, "wpaint_make_validmap gh");
+       gh = BLI_ghash_str_new("wpaint_make_validmap gh");
 
        /* add all names to a hash table */
        for (dg = ob->defbase.first; dg; dg = dg->next) {
index 4f7fc3639f4c997ed4d945f3446c0b0d819f01c9..6a2c3eee7a501d2dc70673c7462fa1b665b8674b 100644 (file)
@@ -232,7 +232,7 @@ static char *gpu_generate_function_prototyps(GHash *hash)
 GPUFunction *GPU_lookup_function(const char *name)
 {
        if (!FUNCTION_HASH) {
-               FUNCTION_HASH = BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp, "GPU_lookup_function gh");
+               FUNCTION_HASH = BLI_ghash_str_new("GPU_lookup_function gh");
                gpu_parse_functions_string(FUNCTION_HASH, glsl_material_library);
                /*FUNCTION_PROTOTYPES = gpu_generate_function_prototyps(FUNCTION_HASH);
                FUNCTION_LIB = GPU_shader_create_lib(datatoc_gpu_shader_material_glsl);*/
@@ -375,8 +375,8 @@ static void codegen_set_unique_ids(ListBase *nodes)
        GPUOutput *output;
        int id = 1, texid = 0;
 
-       bindhash= BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "codegen_set_unique_ids1 gh");
-       definehash= BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "codegen_set_unique_ids2 gh");
+       bindhash= BLI_ghash_ptr_new("codegen_set_unique_ids1 gh");
+       definehash= BLI_ghash_ptr_new("codegen_set_unique_ids2 gh");
 
        for (node=nodes->first; node; node=node->next) {
                for (input=node->inputs.first; input; input=input->next) {
index 472278340e57289eee231fc573c7ce1ade0dea40..80c80d02e06136213cdee12f89a76181285cf144 100644 (file)
@@ -496,7 +496,7 @@ static void init_structDNA(SDNA *sdna, int do_endian_swap)
 
 #ifdef WITH_DNA_GHASH
                /* create a ghash lookup to speed up */
-               sdna->structs_map = BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp, "init_structDNA gh");
+               sdna->structs_map = BLI_ghash_str_new("init_structDNA gh");
 
                for (nr = 0; nr < sdna->nr_structs; nr++) {
                        sp = sdna->structs[nr];
index 3079ba8c8d8b0d1ed1f8d81b838fbe3f1ebc9775..0a07887f19687eb1f906585e6b15f173cbfc03c2 100644 (file)
@@ -74,7 +74,7 @@ void RNA_init(void)
 
        for (srna = BLENDER_RNA.structs.first; srna; srna = srna->cont.next) {
                if (!srna->cont.prophash) {
-                       srna->cont.prophash = BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp, "RNA_init gh");
+                       srna->cont.prophash = BLI_ghash_str_new("RNA_init gh");
 
                        for (prop = srna->cont.properties.first; prop; prop = prop->next)
                                if (!(prop->flag & PROP_BUILTIN))
index 39344aad5a91f2b2b4569aa0b982b681e4d03ba1..1b4d9444fd9437861ebde67d49cbf2cdad5b10f0 100644 (file)
@@ -381,7 +381,7 @@ static DerivedMesh *ConvertCSGDescriptorsToDerivedMesh(
        }
 
        // a hash table to remap materials to indices
-       material_hash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "CSG_mat gh");
+       material_hash = BLI_ghash_ptr_new("CSG_mat gh");
 
        if (mat)
                *totmat = 0;
index 9285ec6674ca1b8d9783ff724eb8dc440ebd633a..121b0ee89e3d61dba545a4eaca2b48a6ec8a6a39 100644 (file)
@@ -90,13 +90,10 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *UNUSED(ob),
        MLoop *ml_dst, *ml_src /*, *mloop_dst */;
        GHashIterator *hashIter;
        /* maps vert indices in old mesh to indices in new mesh */
-       GHash *vertHash = BLI_ghash_new(BLI_ghashutil_inthash,
-                                       BLI_ghashutil_intcmp, "build ve apply gh");
+       GHash *vertHash = BLI_ghash_int_new("build ve apply gh");
        /* maps edge indices in new mesh to indices in old mesh */
-       GHash *edgeHash = BLI_ghash_new(BLI_ghashutil_inthash,
-                                       BLI_ghashutil_intcmp, "build ed apply gh");
-       GHash *edgeHash2 = BLI_ghash_new(BLI_ghashutil_inthash,
-                                        BLI_ghashutil_intcmp, "build ed apply gh");
+       GHash *edgeHash = BLI_ghash_int_new("build ed apply gh");
+       GHash *edgeHash2 = BLI_ghash_int_new("build ed apply gh");
 
        const int numVert_src = dm->getNumVerts(dm);
        const int numEdge_src = dm->getNumEdges(dm);
index 396e48df50c92324b6fd8119f74cf68628f991fe..5206aa281f7178a44d6d0d3c39835ebc1552b83d 100644 (file)
@@ -167,7 +167,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
                 * - vgroups to indices -> vgroupHash  (string, int)
                 * - bones to vgroup indices -> boneHash (index of vgroup, dummy)
                 */
-               vgroupHash = BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp, "mask vgroup gh");
+               vgroupHash = BLI_ghash_str_new("mask vgroup gh");
                
                /* build mapping of names of vertex groups to indices */
                for (i = 0, def = ob->defbase.first; def; def = def->next, i++) 
@@ -191,7 +191,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
                }
                
                /* hashes for quickly providing a mapping from old to new - use key=oldindex, value=newindex */
-               vertHash = BLI_ghash_new(BLI_ghashutil_inthash, BLI_ghashutil_intcmp, "mask vert gh");
+               vertHash = BLI_ghash_int_new("mask vert gh");
                
                /* add vertices which exist in vertexgroups into vertHash for filtering */
                for (i = 0, dv = dvert; i < maxVerts; i++, dv++) {
@@ -239,7 +239,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
                        return dm;
                        
                /* hashes for quickly providing a mapping from old to new - use key=oldindex, value=newindex */
-               vertHash = BLI_ghash_new(BLI_ghashutil_inthash, BLI_ghashutil_intcmp, "mask vert2 bh");
+               vertHash = BLI_ghash_int_new("mask vert2 bh");
                
                /* add vertices which exist in vertexgroup into ghash for filtering */
                for (i = 0, dv = dvert; i < maxVerts; i++, dv++) {
@@ -262,8 +262,8 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
        }
 
        /* hashes for quickly providing a mapping from old to new - use key=oldindex, value=newindex */
-       edgeHash = BLI_ghash_new(BLI_ghashutil_inthash, BLI_ghashutil_intcmp, "mask ed2 gh");
-       polyHash = BLI_ghash_new(BLI_ghashutil_inthash, BLI_ghashutil_intcmp, "mask fa2 gh");
+       edgeHash = BLI_ghash_int_new("mask ed2 gh");
+       polyHash = BLI_ghash_int_new("mask fa2 gh");
        
        mpoly = dm->getPolyArray(dm);
        mloop = dm->getLoopArray(dm);
index 6c1e811aae0aa241471f6f8e8ad29bc1246e41df..f20e029c7b6832bf0c0341d976dcea32b187da0b 100644 (file)
@@ -176,13 +176,13 @@ static GHash *id_weakref_pool_get(ID *id)
        }
        else {
                /* first time, allocate pool */
-               id_weakref_pool = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "rna_global_pool");
+               id_weakref_pool = BLI_ghash_ptr_new("rna_global_pool");
                weakinfo_hash = NULL;
        }
 
        if (weakinfo_hash == NULL) {
                /* we're using a ghash as a set, could use libHX's HXMAP_SINGULAR but would be an extra dep. */
-               weakinfo_hash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "rna_id");
+               weakinfo_hash = BLI_ghash_ptr_new("rna_id");
                BLI_ghash_insert(id_weakref_pool, (void *)id, weakinfo_hash);
        }
 
index f16c1b5e673189aa6b602b0d590342a02483bd9c..c2b0e1e777f8c3dec079536a8931c84e0890475b 100644 (file)
@@ -902,7 +902,7 @@ static float *get_object_orco(Render *re, Object *ob)
        float *orco;
 
        if (!re->orco_hash)
-               re->orco_hash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "get_object_orco gh");
+               re->orco_hash = BLI_ghash_ptr_new("get_object_orco gh");
 
        orco = BLI_ghash_lookup(re->orco_hash, ob);
 
@@ -924,7 +924,7 @@ static float *get_object_orco(Render *re, Object *ob)
 static void set_object_orco(Render *re, void *ob, float *orco)
 {
        if (!re->orco_hash)
-               re->orco_hash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "set_object_orco gh");
+               re->orco_hash = BLI_ghash_ptr_new("set_object_orco gh");
        
        BLI_ghash_insert(re->orco_hash, ob, orco);
 }
index c8a37998169bebe0fb478aa82210e258b3f29401..690598d8c05fd0e05b7c9467e462d3cde5ff058b 100644 (file)
@@ -990,7 +990,7 @@ void make_sss_tree(Render *re)
 {
        Material *mat;
        
-       re->sss_hash= BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "make_sss_tree gh");
+       re->sss_hash= BLI_ghash_ptr_new("make_sss_tree gh");
 
        re->i.infostr= "SSS preprocessing";
        re->stats_draw(re->sdh, &re->i);
index 6690425967cf703f8ff9f211bd5be2a261cada66..02d342754ea8b2f507a192bf49ebc6381a4c059e 100644 (file)
@@ -333,8 +333,8 @@ StrandShadeCache *strand_shade_cache_create(void)
        StrandShadeCache *cache;
 
        cache= MEM_callocN(sizeof(StrandShadeCache), "StrandShadeCache");
-       cache->resulthash= BLI_ghash_new(BLI_ghashutil_pairhash, BLI_ghashutil_paircmp, "strand_shade_cache_create1 gh");
-       cache->refcounthash= BLI_ghash_new(BLI_ghashutil_pairhash, BLI_ghashutil_paircmp, "strand_shade_cache_create2 gh");
+       cache->resulthash= BLI_ghash_pair_new("strand_shade_cache_create1 gh");
+       cache->refcounthash= BLI_ghash_pair_new("strand_shade_cache_create2 gh");
        cache->memarena= BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, "strand shade cache arena");
        
        return cache;
index 7285e155dc61b9fd5a8e992e62cf9dc93da4efac..a34d294461c6e206aa02b862fd227e528d5209e5 100644 (file)
@@ -183,7 +183,7 @@ void WM_menutype_freelink(MenuType *mt)
 /* called on initialize WM_init() */
 void WM_menutype_init(void)
 {
-       menutypes_hash = BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp, "menutypes_hash gh");
+       menutypes_hash = BLI_ghash_str_new("menutypes_hash gh");
 }
 
 void WM_menutype_free(void)
index c18625c0168914084fe4894337a9c45971227f67..7f3a93258da4d0d3f9b7931bbb47bf55cd592d62 100644 (file)
@@ -3740,7 +3740,7 @@ void wm_operatortype_free(void)
 /* called on initialize WM_init() */
 void wm_operatortype_init(void)
 {
-       global_ops_hash = BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp, "wm_operatortype_init gh");
+       global_ops_hash = BLI_ghash_str_new("wm_operatortype_init gh");
 
        WM_operatortype_append(WM_OT_window_duplicate);
        WM_operatortype_append(WM_OT_read_homefile);