Cool VL Viewer forum

View unanswered posts | View active topics It is currently 2020-10-27 20:36:15



Reply to topic  [ 2 posts ] 
Remove useless std::list in lljoint mChildren 
Author Message

Joined: 2011-10-07 10:39:20
Posts: 104
Reply with quote
It seems the std::list for mChildren is mostly useless. A std::vector seems better and just needs a tiny change that actually looks like and improvment as well.

Code:
*** linden_orig/indra/llcharacter/lljoint.cpp   Fri Jul 24 00:53:17 2020
--- linden/indra/llcharacter/lljoint.cpp   Thu Oct  8 01:08:36 2020
***************
*** 345,351 ****
     {
        child_list_t::iterator curiter = iter++;
        LLJoint* joint = *curiter;
-       mChildren.erase(curiter);
        if (joint)
        {
           joint->mXform.setParent(NULL);
--- 345,350 ----
***************
*** 357,362 ****
--- 356,362 ----
           llwarns << "Found a NULL joint during children removal" << llendl;
        }
     }
+    mChildren.clear();
  }
 
  void LLJoint::setPosition(const LLVector3& requested_pos, bool do_override)*** C:/devel/sl/cool/linden/indra/llcharacter/lljoint.h   Thu Oct  8 00:36:51 2020
*** linden/indra/llcharacter/lljoint.h   Thu Oct  8 00:36:51 2020
--- linden_orig/indra/llcharacter/lljoint.h   Fri Jul 24 00:51:51 2020
***************
*** 344,350 ****
     U32                  mDirtyFlags;
 
     // Child joints
!    typedef std::vector<LLJoint*> child_list_t;
     child_list_t         mChildren;
 
     // Position overrides
--- 344,350 ----
     U32                  mDirtyFlags;
 
     // Child joints
!    typedef std::list<LLJoint*> child_list_t;
     child_list_t         mChildren;
 
     // Position overrides


2020-10-07 23:30:33
Profile

Joined: 2009-03-17 18:42:51
Posts: 4378
Reply with quote
kathrine wrote:
It seems the std::list for mChildren is mostly useless.
Not really, no... :lol: The children joints list is totally essential.

Quote:
A std::vector seems better and just needs a tiny change that actually looks like and improvment as well.
Indeed, the std::list is an over-kill.
However one thing to be careful about with std::vector is to avoid erase() operations in them (way more costly than in std::list case, because it will most often involve moving "down" a part of the vector in memory). A nifty trick (as long as you do not care about the entries order, which is the case here) is to copy the last entry of the vector into the entry you remove (if it is not the last entry already) and pop back the last entry of the vector... Only one entry move involved.

I will also use the std::vector indexed access instead of the costly iterators in all the loops using mChildren.

Thanks for pointing this ! :)


2020-10-08 14:14:03
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software.