r18564 by jghali - remove unnecessarily large 'if' block by returning directly when appropriate

scribus-commit scribus-commit at lists.scribus.net
Sat Oct 19 12:59:16 UTC 2013


Author: jghali
Date: Sat Oct 19 12:59:16 2013
New Revision: 18564

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=18564
Log:
remove unnecessarily large 'if' block by returning directly when appropriate

Modified:
    trunk/Scribus/scribus/scribusdoc.cpp

Modified: trunk/Scribus/scribus/scribusdoc.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18564&path=/trunk/Scribus/scribus/scribusdoc.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.cpp (original)
+++ trunk/Scribus/scribus/scribusdoc.cpp Sat Oct 19 12:59:16 2013
@@ -10506,49 +10506,49 @@
 
 void ScribusDoc::updatePic()
 {
-//TODO? Getting the pointer with m_Selection->itemAt(i) over and over again in the loop 
-// seems to be a waste of ressources
-	uint docSelectionCount=m_Selection->count();
-	if (docSelectionCount > 0)
-	{
-		bool toUpdate=false;
-		for (uint i = 0; i < docSelectionCount; ++i)
-		{
-			PageItem* currItem = m_Selection->itemAt(i);
-			if (!currItem)
-				continue;
-			m_updateManager.setUpdatesDisabled();
-			if (currItem->asLatexFrame())
-			{
-				PageItem_LatexFrame *latexframe = currItem->asLatexFrame();
-				latexframe->rerunApplication();
+	//TODO? Getting the pointer with m_Selection->itemAt(i) over and over again in the loop 
+	// seems to be a waste of ressources
+	uint docSelectionCount = m_Selection->count();
+	if (docSelectionCount <= 0)
+		return;
+
+	bool toUpdate=false;
+	for (uint i = 0; i < docSelectionCount; ++i)
+	{
+		PageItem* currItem = m_Selection->itemAt(i);
+		if (!currItem)
+			continue;
+		m_updateManager.setUpdatesDisabled();
+		if (currItem->asLatexFrame())
+		{
+			PageItem_LatexFrame *latexframe = currItem->asLatexFrame();
+			latexframe->rerunApplication();
+			toUpdate = true;
+		}
+#ifdef HAVE_OSG
+		else if ((currItem->asImageFrame()) || (currItem->asOSGFrame()))
+#else
+		else if (currItem->asImageFrame())
+#endif
+		{
+			if (currItem->PictureIsAvailable)
+			{
+				int fho = currItem->imageFlippedH();
+				int fvo = currItem->imageFlippedV();
+				double imgX = currItem->imageXOffset();
+				double imgY = currItem->imageYOffset();
+				loadPict(currItem->Pfile, currItem, true);
+				currItem->setImageFlippedH(fho);
+				currItem->setImageFlippedV(fvo);
+				currItem->setImageXOffset(imgX);
+				currItem->setImageYOffset(imgY);
 				toUpdate = true;
 			}
-#ifdef HAVE_OSG
-			else if ((currItem->asImageFrame()) || (currItem->asOSGFrame()))
-#else
-			else if (currItem->asImageFrame())
-#endif
-			{
-				if (currItem->PictureIsAvailable)
-				{
-					int fho = currItem->imageFlippedH();
-					int fvo = currItem->imageFlippedV();
-					double imgX = currItem->imageXOffset();
-					double imgY = currItem->imageYOffset();
-					loadPict(currItem->Pfile, currItem, true);
-					currItem->setImageFlippedH(fho);
-					currItem->setImageFlippedV(fvo);
-					currItem->setImageXOffset(imgX);
-					currItem->setImageYOffset(imgY);
-					toUpdate = true;
-				}
-			}
-			m_updateManager.setUpdatesEnabled();
-		}
-		if (toUpdate)
-			regionsChanged()->update(QRectF());
-	}
+		}
+		m_updateManager.setUpdatesEnabled();
+	}
+	if (toUpdate)
+		regionsChanged()->update(QRectF());
 }
 
 




More information about the scribus-commit mailing list