diff options
Diffstat (limited to 'indra/newview/llviewerobjectlist.cpp')
-rw-r--r-- | indra/newview/llviewerobjectlist.cpp | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp index 9d38954d8b..db5684665b 100644 --- a/indra/newview/llviewerobjectlist.cpp +++ b/indra/newview/llviewerobjectlist.cpp @@ -1343,18 +1343,29 @@ void LLViewerObjectList::cleanDeadObjects(BOOL use_timer) S32 num_removed = 0; LLViewerObject *objectp; - for (vobj_list_t::iterator iter = mObjects.begin(); iter != mObjects.end(); ) + + vobj_list_t::reverse_iterator target = mObjects.rbegin(); + + vobj_list_t::iterator iter = mObjects.begin(); + for ( ; iter != mObjects.end(); ) { - // Scan for all of the dead objects and remove any "global" references to them. + // Scan for all of the dead objects and put them all on the end of the list with no ref count ops objectp = *iter; + if (objectp == NULL) + { //we caught up to the dead tail + break; + } + if (objectp->isDead()) { - iter = mObjects.erase(iter); + LLPointer<LLViewerObject>::swap(*iter, *target); + *target = NULL; + ++target; num_removed++; - if (num_removed == mNumDeadObjects) + if (num_removed == mNumDeadObjects || iter->isNull()) { - // We've cleaned up all of the dead objects. + // We've cleaned up all of the dead objects or caught up to the dead tail break; } } @@ -1364,6 +1375,11 @@ void LLViewerObjectList::cleanDeadObjects(BOOL use_timer) } } + llassert(num_removed == mNumDeadObjects); + + //erase as a block + mObjects.erase(mObjects.begin()+(mObjects.size()-mNumDeadObjects), mObjects.end()); + // We've cleaned the global object list, now let's do some paranoia testing on objects // before blowing away the dead list. mDeadObjects.clear(); |