Scene object iterator: Replace recursion with loop

This way we are not afraid of recursion being too deep.

That could have happened when having two collections which
are sharing same list of 1000s of objects.
This commit is contained in:
Sergey Sharybin 2017-06-06 11:22:13 +02:00
parent 4e1257f2d8
commit 28e44da860
1 changed files with 7 additions and 11 deletions

View File

@ -584,18 +584,14 @@ void BKE_scene_objects_iterator_begin(BLI_Iterator *iter, void *data_in)
*/
static LinkData *object_base_unique(GSet *gs, LinkData *link)
{
if (link == NULL) {
return NULL;
}
Object *ob = link->data;
if (!BLI_gset_haskey(gs, ob)) {
BLI_gset_add(gs, ob);
return link;
}
else {
return object_base_unique(gs, link->next);
for (; link != NULL; link = link->next) {
Object *ob = link->data;
if (!BLI_gset_haskey(gs, ob)) {
BLI_gset_add(gs, ob);
return link;
}
}
return NULL;
}
void BKE_scene_objects_iterator_next(BLI_Iterator *iter)