From: srn Date: Thu, 1 Nov 2007 11:39:28 +0000 (+0000) Subject: Optimized FindChild method X-Git-Tag: V4_1_0a3~8 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ff034cfbffd298a07baff495b2607cdb875e73b9;p=modules%2Fkernel.git Optimized FindChild method --- diff --git a/src/DF/DF_Label.cxx b/src/DF/DF_Label.cxx index 682a4ca5a..8bfd113ad 100644 --- a/src/DF/DF_Label.cxx +++ b/src/DF/DF_Label.cxx @@ -296,8 +296,16 @@ DF_Label DF_Label::FindChild(int theTag, bool isCreate) DF_LabelNode *aLabel = NULL, *aPrevious = NULL, *aNext = NULL; if(!_node->_firstChild && !isCreate) return DF_Label(); - if(_node->_lastChild && _node->_lastChild->_tag < theTag) { //Incremental addition of children - aPrevious = _node->_lastChild; + if(_node->_firstChild && _node->_firstChild->_tag == theTag) + return DF_Label(_node->_firstChild); + + if(_node->_lastChild) { + if( _node->_lastChild->_tag == theTag) { + return DF_Label(_node->_lastChild); + } + else if( _node->_lastChild->_tag < theTag) { //Incremental addition of children + aPrevious = _node->_lastChild; + } } else { aLabel = _node->_firstChild; @@ -331,7 +339,9 @@ DF_Label DF_Label::FindChild(int theTag, bool isCreate) } if(!_node->_firstChild || (aNext && aNext == _node->_firstChild) ) _node->_firstChild = aChild; - if(!aNext) _node->_lastChild = aChild; + if(!aNext) { + _node->_lastChild = aChild; + } return aChild; }