Simplify a bit iterator + remove double check
Change-Id: I4a12bacc1a3774741cf4bf3eb6770e16d0cecc6e Reviewed-on: https://gerrit.libreoffice.org/5639 Reviewed-by: Thorsten Behrens <tbehrens@suse.com> Tested-by: Thorsten Behrens <tbehrens@suse.com>
This commit is contained in:
parent
5e9137c963
commit
8763c77c39
1 changed files with 7 additions and 14 deletions
|
@ -436,23 +436,16 @@ void SAL_CALL MutableTreeNode::removeChildByIndex( sal_Int32 nChildIndex ) throw
|
|||
{
|
||||
::osl::Guard< ::osl::Mutex > aGuard( maMutex );
|
||||
|
||||
if( (nChildIndex < 0) || (nChildIndex >= (sal_Int32)maChildren.size()) )
|
||||
throw IndexOutOfBoundsException();
|
||||
|
||||
MutableTreeNodeRef xImpl;
|
||||
|
||||
if( (nChildIndex >= 0) && (nChildIndex < (sal_Int32)maChildren.size()) )
|
||||
{
|
||||
TreeNodeVector::iterator aIter( maChildren.begin() );
|
||||
while( nChildIndex-- && (aIter != maChildren.end()) )
|
||||
++aIter;
|
||||
TreeNodeVector::iterator aIter( maChildren.begin() );
|
||||
std::advance(aIter, nChildIndex);
|
||||
|
||||
if( aIter != maChildren.end() )
|
||||
{
|
||||
xImpl = (*aIter);
|
||||
maChildren.erase( aIter );
|
||||
}
|
||||
}
|
||||
|
||||
if( !xImpl.is() )
|
||||
throw IndexOutOfBoundsException();
|
||||
xImpl = (*aIter);
|
||||
maChildren.erase( aIter );
|
||||
|
||||
xImpl->setParent(0);
|
||||
xImpl->mbIsInserted = false;
|
||||
|
|
Loading…
Reference in a new issue