r25069 by craig - Code cleanup: reduce unnecessary QString allocations with better use of
scribus-commit
scribus-commit at lists.scribus.net
Mon Mar 28 20:03:39 UTC 2022
Author: craig
Date: Mon Mar 28 20:03:39 2022
New Revision: 25069
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=25069
Log:
Code cleanup: reduce unnecessary QString allocations with better use of
.remove/.setNum
Modified:
trunk/Scribus/scribus/collect4output.cpp
trunk/Scribus/scribus/guidemanagercore.cpp
trunk/Scribus/scribus/imagedataloaders/scimgdataloader_ps.cpp
trunk/Scribus/scribus/palettes/paletteloader_ps.cpp
trunk/Scribus/scribus/pluginmanager.cpp
trunk/Scribus/scribus/plugins/gettext/htmlim/htmlreader.cpp
trunk/Scribus/scribus/plugins/gettext/sxwim/contentreader.cpp
trunk/Scribus/scribus/plugins/gettext/sxwim/stylereader.cpp
trunk/Scribus/scribus/plugins/gettext/textfilter/textfilter.cpp
trunk/Scribus/scribus/plugins/import/ai/importai.cpp
trunk/Scribus/scribus/plugins/import/idml/importidml.cpp
trunk/Scribus/scribus/plugins/import/xps/importxps.cpp
trunk/Scribus/scribus/ui/layers.cpp
trunk/Scribus/scribus/ui/pagepalette_pages.cpp
Modified: trunk/Scribus/scribus/collect4output.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=25069&path=/trunk/Scribus/scribus/collect4output.cpp
==============================================================================
--- trunk/Scribus/scribus/collect4output.cpp (original)
+++ trunk/Scribus/scribus/collect4output.cpp Mon Mar 28 20:03:39 2022
@@ -170,7 +170,7 @@
else
{
if (newName.endsWith(".gz"))
- newName = newName.remove(".gz");
+ newName.remove(".gz");
}
if (!overwrite(ScCore->primaryMainWindow(), newName))
Modified: trunk/Scribus/scribus/guidemanagercore.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=25069&path=/trunk/Scribus/scribus/guidemanagercore.cpp
==============================================================================
--- trunk/Scribus/scribus/guidemanagercore.cpp (original)
+++ trunk/Scribus/scribus/guidemanagercore.cpp Mon Mar 28 20:03:39 2022
@@ -682,7 +682,7 @@
Guides tmpGuides = page->guides.horizontals(type);
for (it = tmpGuides.begin(); it != tmpGuides.end(); ++it)
{
- tmp = tmp.setNum((*it));
+ tmp.setNum((*it));
retval += tmp + " ";
}
return retval;
@@ -696,7 +696,7 @@
Guides tmpGuides = page->guides.verticals(type);
for (it = tmpGuides.begin(); it != tmpGuides.end(); ++it)
{
- tmp = tmp.setNum((*it));
+ tmp.setNum((*it));
retval += tmp + " ";
}
return retval;
Modified: trunk/Scribus/scribus/imagedataloaders/scimgdataloader_ps.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=25069&path=/trunk/Scribus/scribus/imagedataloaders/scimgdataloader_ps.cpp
==============================================================================
--- trunk/Scribus/scribus/imagedataloaders/scimgdataloader_ps.cpp (original)
+++ trunk/Scribus/scribus/imagedataloaders/scimgdataloader_ps.cpp Mon Mar 28 20:03:39 2022
@@ -121,7 +121,7 @@
tmp = readLineFromDataStream(ts);
if (tmp.startsWith("%%BeginFont:"))
{
- tmp = tmp.remove("%%BeginFont:");
+ tmp.remove("%%BeginFont:");
ScTextStream ts2(&tmp, QIODevice::ReadOnly);
QString tmp2;
ts2 >> tmp2;
@@ -207,7 +207,7 @@
m_Creator = tmp.remove("%%Creator: ");
if (tmp.startsWith("%%Pages: "))
{
- tmp = tmp.remove("%%Pages: ");
+ tmp.remove("%%Pages: ");
bool ok;
int pages = tmp.toInt( &ok );
if (ok)
@@ -259,10 +259,10 @@
}
if (tmp.startsWith("%%PlateFile: ("))
{
- tmp = tmp.remove("%%PlateFile: (");
+ tmp.remove("%%PlateFile: (");
int endNam = tmp.indexOf(")");
QString plateNam = tmp.left(endNam);
- tmp = tmp.remove(plateNam+")");
+ tmp.remove(plateNam+")");
ScTextStream ts2(&tmp, QIODevice::ReadOnly);
QString posStr, dummy, lenStr;
ts2 >> dummy >> posStr >> lenStr;
@@ -270,7 +270,7 @@
{
if (posStr.startsWith("#"))
{
- posStr = posStr.remove(0, 1);
+ posStr.remove(0, 1);
uint pos = posStr.toUInt();
uint len = lenStr.toUInt();
struct plateOffsets offs;
@@ -295,7 +295,7 @@
}
if (tmp.startsWith("%%DocumentFonts:"))
{
- tmp = tmp.remove("%%DocumentFonts:");
+ tmp.remove("%%DocumentFonts:");
ScTextStream ts2(&tmp, QIODevice::ReadOnly);
QString tmp2;
ts2 >> tmp2;
@@ -312,7 +312,7 @@
ts.device()->seek(oldPos);
break;
}
- tmp = tmp.remove(0,3);
+ tmp.remove(0,3);
ScTextStream ts2(&tmp, QIODevice::ReadOnly);
QString tmp2;
ts2 >> tmp2;
@@ -325,13 +325,13 @@
}
if (tmp.startsWith("%%CMYKCustomColor"))
{
- tmp = tmp.remove(0,18);
+ tmp.remove(0,18);
ScTextStream ts2(&tmp, QIODevice::ReadOnly);
ts2 >> c >> m >> y >> k;
FarNam = ts2.readAll();
FarNam = FarNam.trimmed();
- FarNam = FarNam.remove(0,1);
- FarNam = FarNam.remove(FarNam.length()-1,1);
+ FarNam.remove(0,1);
+ FarNam.remove(FarNam.length()-1,1);
cc = ScColor(static_cast<int>(255 * c), static_cast<int>(255 * m), static_cast<int>(255 * y), static_cast<int>(255 * k));
cc.setSpotColor(true);
m_CustColors.insert(FarNam, cc);
Modified: trunk/Scribus/scribus/palettes/paletteloader_ps.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=25069&path=/trunk/Scribus/scribus/palettes/paletteloader_ps.cpp
==============================================================================
--- trunk/Scribus/scribus/palettes/paletteloader_ps.cpp (original)
+++ trunk/Scribus/scribus/palettes/paletteloader_ps.cpp Mon Mar 28 20:03:39 2022
@@ -52,15 +52,15 @@
else
{
if (tmp.startsWith("%%CMYKCustomColor"))
- tmp = tmp.remove(0,18);
+ tmp.remove(0,18);
else if (tmp.startsWith("%%CMYKProcessColor"))
- tmp = tmp.remove(0,19);
+ tmp.remove(0,19);
ScTextStream ts2(&tmp, QIODevice::ReadOnly);
ts2 >> c >> m >> y >> k;
colorName = ts2.readAll();
colorName = colorName.trimmed();
- colorName = colorName.remove(0,1);
- colorName = colorName.remove(colorName.length()-1,1);
+ colorName.remove(0,1);
+ colorName.remove(colorName.length()-1,1);
colorName = colorName.simplified();
cc = ScColor(qRound(255 * c), qRound(255 * m), qRound(255 * y), qRound(255 * k));
cc.setSpotColor(true);
@@ -75,13 +75,13 @@
ts.device()->seek(oldPos);
break;
}
- tmp = tmp.remove(0,3);
+ tmp.remove(0,3);
ScTextStream ts2(&tmp, QIODevice::ReadOnly);
ts2 >> c >> m >> y >> k;
colorName = ts2.readAll();
colorName = colorName.trimmed();
- colorName = colorName.remove(0,1);
- colorName = colorName.remove(colorName.length()-1,1);
+ colorName.remove(0,1);
+ colorName.remove(colorName.length()-1,1);
colorName = colorName.simplified();
cc = ScColor(qRound(255 * c), qRound(255 * m), qRound(255 * y), qRound(255 * k));
cc.setSpotColor(true);
@@ -97,15 +97,15 @@
else
{
if (tmp.startsWith("%%RGBCustomColor"))
- tmp = tmp.remove(0,17);
+ tmp.remove(0,17);
else if (tmp.startsWith("%%RGBProcessColor"))
- tmp = tmp.remove(0,18);
+ tmp.remove(0,18);
ScTextStream ts2(&tmp, QIODevice::ReadOnly);
ts2 >> c >> m >> y;
colorName = ts2.readAll();
colorName = colorName.trimmed();
- colorName = colorName.remove(0,1);
- colorName = colorName.remove(colorName.length()-1,1);
+ colorName.remove(0,1);
+ colorName.remove(colorName.length()-1,1);
colorName = colorName.simplified();
cc = ScColor(qRound(255 * c), qRound(255 * m), qRound(255 * y));
if (!colorName.isEmpty())
@@ -119,13 +119,13 @@
ts.device()->seek(oldPos);
break;
}
- tmp = tmp.remove(0,3);
+ tmp.remove(0,3);
ScTextStream ts2(&tmp, QIODevice::ReadOnly);
ts2 >> c >> m >> y;
colorName = ts2.readAll();
colorName = colorName.trimmed();
- colorName = colorName.remove(0,1);
- colorName = colorName.remove(colorName.length()-1,1);
+ colorName.remove(0,1);
+ colorName.remove(colorName.length()-1,1);
colorName = colorName.simplified();
cc = ScColor(qRound(255 * c), qRound(255 * m), qRound(255 * y));
if (!colorName.isEmpty())
Modified: trunk/Scribus/scribus/pluginmanager.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=25069&path=/trunk/Scribus/scribus/pluginmanager.cpp
==============================================================================
--- trunk/Scribus/scribus/pluginmanager.cpp (original)
+++ trunk/Scribus/scribus/pluginmanager.cpp Mon Mar 28 20:03:39 2022
@@ -134,7 +134,7 @@
QFileInfo fi(fileName);
QString baseName(fi.baseName());
if (baseName.startsWith("lib"))
- baseName = baseName.remove(0, 3);
+ baseName.remove(0, 3);
if (baseName.endsWith(platformDllExtension()))
baseName.chop(1 + platformDllExtension().length());
// check name
Modified: trunk/Scribus/scribus/plugins/gettext/htmlim/htmlreader.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=25069&path=/trunk/Scribus/scribus/plugins/gettext/htmlim/htmlreader.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/gettext/htmlim/htmlreader.cpp (original)
+++ trunk/Scribus/scribus/plugins/gettext/htmlim/htmlreader.cpp Mon Mar 28 20:03:39 2022
@@ -335,7 +335,7 @@
if ((!href.isEmpty()) && ((href.indexOf("//") != -1) ||
(href.indexOf("mailto:") != -1) || (href.indexOf("www") != -1)))
{
- href = href.remove("mailto:");
+ href.remove("mailto:");
writer->append(QString(" [%1]").arg(extIndex), pstyle);
extLinks += QString("[%1] ").arg(extIndex) + href + "\n";
++extIndex;
Modified: trunk/Scribus/scribus/plugins/gettext/sxwim/contentreader.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=25069&path=/trunk/Scribus/scribus/plugins/gettext/sxwim/contentreader.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/gettext/sxwim/contentreader.cpp (original)
+++ trunk/Scribus/scribus/plugins/gettext/sxwim/contentreader.cpp Mon Mar 28 20:03:39 2022
@@ -169,8 +169,8 @@
bool ContentReader::characters(const QString &ch)
{
QString tmp(ch);
- tmp = tmp.remove("\n");
- tmp = tmp.remove(""); // Remove all OO.o hyphenation chars
+ tmp.remove("\n");
+ tmp.remove(""); // Remove all OO.o hyphenation chars
// Unneeded as scribus now also use standard unicode non-breakable space
// tmp = tmp.replace(QChar(160), SpecialChars::NBSPACE); // replace OO.o nbsp with Scribus nbsp
if (append > 0)
Modified: trunk/Scribus/scribus/plugins/gettext/sxwim/stylereader.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=25069&path=/trunk/Scribus/scribus/plugins/gettext/sxwim/stylereader.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/gettext/sxwim/stylereader.cpp (original)
+++ trunk/Scribus/scribus/plugins/gettext/sxwim/stylereader.cpp Mon Mar 28 20:03:39 2022
@@ -170,7 +170,7 @@
else if (attrName == "fo:font-family")
{
family = attr.value();
- family = family.remove("'");
+ family.remove("'");
}
else if (attrName == "style:font-style-name")
style += attr.value() + " ";
Modified: trunk/Scribus/scribus/plugins/gettext/textfilter/textfilter.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=25069&path=/trunk/Scribus/scribus/plugins/gettext/textfilter/textfilter.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/gettext/textfilter/textfilter.cpp (original)
+++ trunk/Scribus/scribus/plugins/gettext/textfilter/textfilter.cpp Mon Mar 28 20:03:39 2022
@@ -106,9 +106,9 @@
{
case REMOVE:
if (useRegexp)
- text = text.remove(rx);
+ text.remove(rx);
else
- text = text.remove(regExp);
+ text.remove(regExp);
break;
case REPLACE:
if (useRegexp)
Modified: trunk/Scribus/scribus/plugins/import/ai/importai.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=25069&path=/trunk/Scribus/scribus/plugins/import/ai/importai.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/ai/importai.cpp (original)
+++ trunk/Scribus/scribus/plugins/import/ai/importai.cpp Mon Mar 28 20:03:39 2022
@@ -803,15 +803,15 @@
else
{
if (tmp.startsWith("%%CMYKCustomColor"))
- tmp = tmp.remove(0,18);
+ tmp.remove(0,18);
else if (tmp.startsWith("%%CMYKProcessColor"))
- tmp = tmp.remove(0,19);
+ tmp.remove(0,19);
ScTextStream ts2(&tmp, QIODevice::ReadOnly);
ts2 >> c >> m >> yc >> k;
FarNam = ts2.readAll();
FarNam = FarNam.trimmed();
- FarNam = FarNam.remove(0,1);
- FarNam = FarNam.remove(FarNam.length()-1,1);
+ FarNam.remove(0,1);
+ FarNam.remove(FarNam.length()-1,1);
FarNam = FarNam.simplified();
QByteArray farN;
for (int a = 0; a < FarNam.length(); a++)
@@ -836,13 +836,13 @@
ts.device()->seek(oldPos);
break;
}
- tmp = tmp.remove(0,3);
+ tmp.remove(0,3);
ScTextStream ts2(&tmp, QIODevice::ReadOnly);
ts2 >> c >> m >> yc >> k;
FarNam = ts2.readAll();
FarNam = FarNam.trimmed();
- FarNam = FarNam.remove(0,1);
- FarNam = FarNam.remove(FarNam.length()-1,1);
+ FarNam.remove(0,1);
+ FarNam.remove(FarNam.length()-1,1);
FarNam = FarNam.simplified();
QByteArray farN;
for (int a = 0; a < FarNam.length(); a++)
@@ -868,15 +868,15 @@
else
{
if (tmp.startsWith("%%RGBCustomColor"))
- tmp = tmp.remove(0,17);
+ tmp.remove(0,17);
else if (tmp.startsWith("%%RGBProcessColor"))
- tmp = tmp.remove(0,18);
+ tmp.remove(0,18);
ScTextStream ts2(&tmp, QIODevice::ReadOnly);
ts2 >> c >> m >> yc;
FarNam = ts2.readAll();
FarNam = FarNam.trimmed();
- FarNam = FarNam.remove(0,1);
- FarNam = FarNam.remove(FarNam.length()-1,1);
+ FarNam.remove(0,1);
+ FarNam.remove(FarNam.length()-1,1);
FarNam = FarNam.simplified();
QByteArray farN;
for (int a = 0; a < FarNam.length(); a++)
@@ -900,13 +900,13 @@
ts.device()->seek(oldPos);
break;
}
- tmp = tmp.remove(0,3);
+ tmp.remove(0,3);
ScTextStream ts2(&tmp, QIODevice::ReadOnly);
ts2 >> c >> m >> yc;
FarNam = ts2.readAll();
FarNam = FarNam.trimmed();
- FarNam = FarNam.remove(0,1);
- FarNam = FarNam.remove(FarNam.length()-1,1);
+ FarNam.remove(0,1);
+ FarNam.remove(FarNam.length()-1,1);
FarNam = FarNam.simplified();
QByteArray farN;
for (int a = 0; a < FarNam.length(); a++)
@@ -958,7 +958,7 @@
if (!isX)
{
tmp = tmp.trimmed();
- tmp = tmp.remove(0,1);
+ tmp.remove(0,1);
int en = tmp.indexOf(")");
FarNam = tmp.mid(0, en);
FarNam = FarNam.simplified();
Modified: trunk/Scribus/scribus/plugins/import/idml/importidml.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=25069&path=/trunk/Scribus/scribus/plugins/import/idml/importidml.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/idml/importidml.cpp (original)
+++ trunk/Scribus/scribus/plugins/import/idml/importidml.cpp Mon Mar 28 20:03:39 2022
@@ -3322,7 +3322,7 @@
else
{
QString family = fontBaseName + " " + fontStyle;
- family = family.remove("$ID/");
+ family.remove("$ID/");
if (!PrefsManager::instance().appPrefs.fontPrefs.GFontSub.contains(family))
{
qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
Modified: trunk/Scribus/scribus/plugins/import/xps/importxps.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=25069&path=/trunk/Scribus/scribus/plugins/import/xps/importxps.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/xps/importxps.cpp (original)
+++ trunk/Scribus/scribus/plugins/import/xps/importxps.cpp Mon Mar 28 20:03:39 2022
@@ -1802,7 +1802,7 @@
if (rgbColor.startsWith( "sc#" ))
{
QColor c;
- rgbColor = rgbColor.remove(0,3);
+ rgbColor.remove(0,3);
QStringList co = rgbColor.split(",");
if (co.size() == 3)
{
@@ -1843,7 +1843,7 @@
bool ok;
int hex = alpha.toInt(&ok, 16);
opacity = 1.0 - (hex / 255.0);
- rgbColor = rgbColor.remove(1,2);
+ rgbColor.remove(1,2);
}
else
opacity = 0;
Modified: trunk/Scribus/scribus/ui/layers.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=25069&path=/trunk/Scribus/scribus/ui/layers.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/layers.cpp (original)
+++ trunk/Scribus/scribus/ui/layers.cpp Mon Mar 28 20:03:39 2022
@@ -235,7 +235,7 @@
int layerID = it->ID;
//TODO once "layers" is not set anymore, need to get layer number differently
int layerLevel = m_Doc->layerLevelFromID(layerID);
- tmp = tmp.setNum(layerLevel);
+ tmp.setNum(layerLevel);
int row = layerCount-layerLevel - 1;
QToolButton *pb = new QToolButton(this);
pb->setObjectName(tmp);
Modified: trunk/Scribus/scribus/ui/pagepalette_pages.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=25069&path=/trunk/Scribus/scribus/ui/pagepalette_pages.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/pagepalette_pages.cpp (original)
+++ trunk/Scribus/scribus/ui/pagepalette_pages.cpp Mon Mar 28 20:03:39 2022
@@ -394,7 +394,7 @@
p.setPen(QPen(Qt::black, 0, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
QString tmp(currView->m_doc->getSectionPageNumberForPageIndex(number));
if (tmp.isEmpty())
- tmp = tmp.setNum(number + 1);
+ tmp.setNum(number + 1);
QRegularExpression regExp ("([A-Z]*[0-9]*)( *[\\.|\\-|_] *)(.*)");
QRegularExpressionMatch match = regExp.match(masterPage);
if (match.hasMatch())
More information about the scribus-commit
mailing list