Optimize ghash usage
Avoid double hash calculation.
This commit is contained in:
@@ -681,12 +681,13 @@ static short layer_collection_sync(
|
||||
continue;
|
||||
}
|
||||
|
||||
Base *base = BLI_ghash_lookup(view_layer->object_bases_hash, cob->ob);
|
||||
|
||||
if (base) {
|
||||
void **base_p;
|
||||
Base *base;
|
||||
if (BLI_ghash_ensure_p(view_layer->object_bases_hash, cob->ob, &base_p)) {
|
||||
/* Move from old base list to new base list. Base might have already
|
||||
* been moved to the new base list and the first/last test ensure that
|
||||
* case also works. */
|
||||
base = *base_p;
|
||||
if (!ELEM(base, new_object_bases->first, new_object_bases->last)) {
|
||||
BLI_remlink(&view_layer->object_bases, base);
|
||||
BLI_addtail(new_object_bases, base);
|
||||
@@ -695,8 +696,8 @@ static short layer_collection_sync(
|
||||
else {
|
||||
/* Create new base. */
|
||||
base = object_base_new(cob->ob);
|
||||
*base_p = base;
|
||||
BLI_addtail(new_object_bases, base);
|
||||
BLI_ghash_insert(view_layer->object_bases_hash, base->object, base);
|
||||
}
|
||||
|
||||
int object_restrict = base->object->restrictflag;
|
||||
|
||||
@@ -101,8 +101,7 @@
|
||||
BLI_assert(*(id_pp) == old_id); \
|
||||
} \
|
||||
if (old_id && (_flag & IDWALK_RECURSE)) { \
|
||||
if (!BLI_gset_haskey((_data)->ids_handled, old_id)) { \
|
||||
BLI_gset_add((_data)->ids_handled, old_id); \
|
||||
if (BLI_gset_add((_data)->ids_handled, old_id)) { \
|
||||
if (!(callback_return & IDWALK_RET_STOP_RECURSION)) { \
|
||||
BLI_LINKSTACK_PUSH((_data)->ids_todo, old_id); \
|
||||
} \
|
||||
@@ -320,8 +319,7 @@ static void library_foreach_ID_as_subdata_link(
|
||||
if (flag & IDWALK_RECURSE) {
|
||||
/* Defer handling into main loop, recursively calling BKE_library_foreach_ID_link in IDWALK_RECURSE case is
|
||||
* troublesome, see T49553. */
|
||||
if (!BLI_gset_haskey(data->ids_handled, id)) {
|
||||
BLI_gset_add(data->ids_handled, id);
|
||||
if (BLI_gset_add(data->ids_handled, id)) {
|
||||
BLI_LINKSTACK_PUSH(data->ids_todo, id);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user