r17750 by jghali - #10999: Speed up some loops for very long text in many linked frames

scribus-commit scribus-commit at lists.scribus.net
Fri Aug 3 22:33:53 UTC 2012


Author: jghali
Date: Fri Aug  3 22:33:53 2012
New Revision: 17750

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=17750
Log:
#10999: Speed up some loops for very long text in many linked frames

Modified:
    branches/Version14x/Scribus/scribus/pdflib_core.cpp
    branches/Version14x/Scribus/scribus/plugins/scriptplugin/cmdutil.cpp
    branches/Version14x/Scribus/scribus/scribusdoc.cpp

Modified: branches/Version14x/Scribus/scribus/pdflib_core.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17750&path=/branches/Version14x/Scribus/scribus/pdflib_core.cpp
==============================================================================
--- branches/Version14x/Scribus/scribus/pdflib_core.cpp (original)
+++ branches/Version14x/Scribus/scribus/pdflib_core.cpp Fri Aug  3 22:33:53 2012
@@ -933,7 +933,9 @@
 					ReallyUsed.insert(pgit->itemText.defaultStyle().charStyle().font().replacementName(), DocFonts[pgit->itemText.defaultStyle().charStyle().font().replacementName()]);
 				}
 			}
-			for (uint e = 0; e < static_cast<uint>(pgit->itemText.length()); ++e)
+			uint start = pgit->isTextFrame() ? (uint) pgit->firstInFrame() : 0;
+			uint stop  = pgit->isTextFrame() ? (uint) pgit->lastInFrame() + 1 : (uint) pgit->itemText.length();
+			for (uint e = start; e < stop; ++e)
 			{
 				ReallyUsed.insert(pgit->itemText.charStyle(e).font().replacementName(), DocFonts[pgit->itemText.charStyle(e).font().replacementName()]);
 			}
@@ -957,7 +959,9 @@
 					ReallyUsed.insert(pgit->itemText.defaultStyle().charStyle().font().replacementName(), DocFonts[pgit->itemText.defaultStyle().charStyle().font().replacementName()]);
 				}
 			}
-			for (uint e = 0; e < static_cast<uint>(pgit->itemText.length()); ++e)
+			uint start = pgit->isTextFrame() ? (uint) pgit->firstInFrame() : 0;
+			uint stop  = pgit->isTextFrame() ? (uint) pgit->lastInFrame() + 1 : (uint) pgit->itemText.length();
+			for (uint e = start; e < stop; ++e)
 			{
 				ReallyUsed.insert(pgit->itemText.charStyle(e).font().replacementName(), DocFonts[pgit->itemText.charStyle(e).font().replacementName()]);
 			}
@@ -981,7 +985,9 @@
 					ReallyUsed.insert(pgit->itemText.defaultStyle().charStyle().font().replacementName(), DocFonts[pgit->itemText.defaultStyle().charStyle().font().replacementName()]);
 				}
 			}
-			for (uint e = 0; e < static_cast<uint>(pgit->itemText.length()); ++e)
+			uint start = pgit->isTextFrame() ? (uint) pgit->firstInFrame() : 0;
+			uint stop  = pgit->isTextFrame() ? (uint) pgit->lastInFrame() + 1 : (uint) pgit->itemText.length();
+			for (uint e = start; e < stop; ++e)
 			{
 				ReallyUsed.insert(pgit->itemText.charStyle(e).font().replacementName(), DocFonts[pgit->itemText.charStyle(e).font().replacementName()]);
 			}
@@ -1011,7 +1017,9 @@
 						ReallyUsed.insert(pgit->itemText.defaultStyle().charStyle().font().replacementName(), DocFonts[pgit->itemText.defaultStyle().charStyle().font().replacementName()]);
 					}
 				}
-				for (uint e = 0; e < static_cast<uint>(pgit->itemText.length()); ++e)
+				uint start = pgit->isTextFrame() ? (uint) pgit->firstInFrame() : 0;
+				uint stop  = pgit->isTextFrame() ? (uint) pgit->lastInFrame() + 1 : (uint) pgit->itemText.length();
+				for (uint e = start; e < stop; ++e)
 				{
 					ReallyUsed.insert(pgit->itemText.charStyle(e).font().replacementName(), DocFonts[pgit->itemText.charStyle(e).font().replacementName()]);
 				}

Modified: branches/Version14x/Scribus/scribus/plugins/scriptplugin/cmdutil.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17750&path=/branches/Version14x/Scribus/scribus/plugins/scriptplugin/cmdutil.cpp
==============================================================================
--- branches/Version14x/Scribus/scribus/plugins/scriptplugin/cmdutil.cpp (original)
+++ branches/Version14x/Scribus/scribus/plugins/scriptplugin/cmdutil.cpp Fri Aug  3 22:33:53 2012
@@ -76,7 +76,7 @@
 	for (int c = 0; c < ScCore->primaryMainWindow()->doc->Items->count(); c++)
 	{
 		PageItem *ite = ScCore->primaryMainWindow()->doc->Items->at(c);
-		if (ite->itemType() == PageItem::TextFrame)
+		if ((ite->itemType() == PageItem::TextFrame) && (ite->prevInChain() == NULL))
 		{
 			for (int d = 0; d < ite->itemText.length(); d++)
 			{

Modified: branches/Version14x/Scribus/scribus/scribusdoc.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17750&path=/branches/Version14x/Scribus/scribus/scribusdoc.cpp
==============================================================================
--- branches/Version14x/Scribus/scribus/scribusdoc.cpp (original)
+++ branches/Version14x/Scribus/scribus/scribusdoc.cpp Fri Aug  3 22:33:53 2012
@@ -3154,7 +3154,9 @@
 				Really.insert(it->itemText.defaultStyle().charStyle().font().replacementName(), QMap<uint, FPointArray>());
 			}
 		}*/
-		for (int e = 0; e < it->itemText.length(); ++e)
+		int start = it->isTextFrame() ? it->firstInFrame() : 0;
+		int stop  = it->isTextFrame() ? it->lastInFrame() + 1 : it->itemText.length();
+		for (int e = start; e < stop; ++e)
 		{
 			if (! Really.contains(it->itemText.charStyle(e).font().replacementName()) )
 			{




More information about the scribus-commit mailing list