Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenkernel/intern/collection.c')
-rw-r--r--source/blender/blenkernel/intern/collection.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c
index 42b709104f3..faec986dded 100644
--- a/source/blender/blenkernel/intern/collection.c
+++ b/source/blender/blenkernel/intern/collection.c
@@ -1095,16 +1095,26 @@ static bool collection_object_add(Main *bmain,
}
}
- if (collection_objects == NULL) {
- collection_objects = BLI_gset_ptr_new(__func__);
- LISTBASE_FOREACH (CollectionObject *, collection_object, &collection->gobject) {
- BLI_gset_insert(collection_objects, collection_object->ob);
+ if (objects_len <= 10) {
+ /*
+ * Building a GSet adds overhead. When objects_len is small BLI_findptr is faster.
+ */
+ if (BLI_findptr(&collection->gobject, ob, offsetof(CollectionObject, ob))) {
+ continue;
}
}
-
- if (!BLI_gset_add(collection_objects, ob)) {
- result = false;
- continue;
+ else {
+ if (collection_objects == NULL) {
+ int gobject_len = BLI_listbase_count(&collection->gobject);
+ collection_objects = BLI_gset_ptr_new_ex(__func__, gobject_len + objects_len);
+ LISTBASE_FOREACH (CollectionObject *, collection_object, &collection->gobject) {
+ BLI_gset_insert(collection_objects, collection_object->ob);
+ }
+ }
+ if (!BLI_gset_add(collection_objects, ob)) {
+ result = false;
+ continue;
+ }
}
CollectionObject *cob = MEM_callocN(sizeof(CollectionObject), __func__);