From 0eef7934bc0dc0a3b915c1502bfc0be60d7eb365 Mon Sep 17 00:00:00 2001 From: Renato Araujo Oliveira Filho Date: Wed, 12 Jan 2011 19:30:23 -0300 Subject: Optimized setParent function. Replaced use of find in the children list for check on the current child if his has a parent and if the parent is the same. Fixes bug #556 Reviewer: Marcelo Lira Hugo Parente --- libshiboken/basewrapper.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'libshiboken/basewrapper.cpp') diff --git a/libshiboken/basewrapper.cpp b/libshiboken/basewrapper.cpp index a44a6bf95..737bfadc9 100644 --- a/libshiboken/basewrapper.cpp +++ b/libshiboken/basewrapper.cpp @@ -911,9 +911,9 @@ void setParent(PyObject* parent, PyObject* child) if (!parentIsNull) { if (!parent_->d->parentInfo) parent_->d->parentInfo = new ParentInfo; + // do not re-add a child - ChildrenList& children = parent_->d->parentInfo->children; - if (std::find(children.begin(), children.end(), child_) != children.end()) + if (child_->d->parentInfo && (child_->d->parentInfo->parent == parent_)) return; } -- cgit v1.2.3