[Libreoffice-commits] core.git: toolkit/source

Julien Nabet serval2412 at yahoo.fr
Tue Aug 27 06:11:49 PDT 2013


 toolkit/source/controls/tree/treedatamodel.cxx |   21 +++++++--------------
 1 file changed, 7 insertions(+), 14 deletions(-)

New commits:
commit 8763c77c39507284d45eb79c29977eb0174b66f1
Author: Julien Nabet <serval2412 at yahoo.fr>
Date:   Tue Aug 27 07:25:33 2013 +0200

    Simplify a bit iterator + remove double check
    
    Change-Id: I4a12bacc1a3774741cf4bf3eb6770e16d0cecc6e
    Reviewed-on: https://gerrit.libreoffice.org/5639
    Reviewed-by: Thorsten Behrens <tbehrens at suse.com>
    Tested-by: Thorsten Behrens <tbehrens at suse.com>

diff --git a/toolkit/source/controls/tree/treedatamodel.cxx b/toolkit/source/controls/tree/treedatamodel.cxx
index 891525d..292d685 100644
--- a/toolkit/source/controls/tree/treedatamodel.cxx
+++ b/toolkit/source/controls/tree/treedatamodel.cxx
@@ -436,23 +436,16 @@ void SAL_CALL MutableTreeNode::removeChildByIndex( sal_Int32 nChildIndex ) throw
 {
     ::osl::Guard< ::osl::Mutex > aGuard( maMutex );
 
-    MutableTreeNodeRef xImpl;
+    if( (nChildIndex < 0) || (nChildIndex >= (sal_Int32)maChildren.size()) )
+        throw IndexOutOfBoundsException();
 
-    if( (nChildIndex >= 0) && (nChildIndex < (sal_Int32)maChildren.size()) )
-    {
-        TreeNodeVector::iterator aIter( maChildren.begin() );
-        while( nChildIndex-- && (aIter != maChildren.end()) )
-            ++aIter;
+    MutableTreeNodeRef xImpl;
 
-        if( aIter != maChildren.end() )
-        {
-            xImpl = (*aIter);
-            maChildren.erase( aIter );
-        }
-    }
+    TreeNodeVector::iterator aIter( maChildren.begin() );
+    std::advance(aIter, nChildIndex);
 
-    if( !xImpl.is() )
-        throw IndexOutOfBoundsException();
+    xImpl = (*aIter);
+    maChildren.erase( aIter );
 
     xImpl->setParent(0);
     xImpl->mbIsInserted = false;


More information about the Libreoffice-commits mailing list