prune pointless assignments of QString::replace() and remove() results

they operate in-place.

Change-Id: Iab6f2f6a9f6f67b9d70feb77ec719e424909022d
Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
This commit is contained in:
Oswald Buddenhagen 2014-11-27 15:02:50 +01:00
parent 2b31356ac9
commit aa30f49d6a
7 changed files with 31 additions and 35 deletions

View File

@ -880,10 +880,10 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
QString librarySuffix = project->first("QMAKE_XCODE_LIBRARY_SUFFIX").toQString();
suffixSetting = "$(" + suffixSetting + ")";
if (!librarySuffix.isEmpty()) {
library = library.replace(librarySuffix, suffixSetting);
name = name.remove(librarySuffix);
library.replace(librarySuffix, suffixSetting);
name.remove(librarySuffix);
} else {
library = library.replace(name, name + suffixSetting);
library.replace(name, name + suffixSetting);
}
}
}
@ -1416,22 +1416,21 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
if (plist_in_file.open(QIODevice::ReadOnly)) {
QTextStream plist_in(&plist_in_file);
QString plist_in_text = plist_in.readAll();
plist_in_text = plist_in_text.replace("@ICON@",
plist_in_text.replace("@ICON@",
(project->isEmpty("ICON") ? QString("") : project->first("ICON").toQString().section(Option::dir_sep, -1)));
if (project->first("TEMPLATE") == "app") {
plist_in_text = plist_in_text.replace("@EXECUTABLE@", project->first("QMAKE_ORIG_TARGET").toQString());
plist_in_text.replace("@EXECUTABLE@", project->first("QMAKE_ORIG_TARGET").toQString());
} else {
plist_in_text = plist_in_text.replace("@LIBRARY@", project->first("QMAKE_ORIG_TARGET").toQString());
plist_in_text.replace("@LIBRARY@", project->first("QMAKE_ORIG_TARGET").toQString());
}
QString bundlePrefix = project->first("QMAKE_TARGET_BUNDLE_PREFIX").toQString();
if (bundlePrefix.isEmpty())
bundlePrefix = "com.yourcompany";
plist_in_text = plist_in_text.replace("@BUNDLEIDENTIFIER@", bundlePrefix + "." + QLatin1String("${PRODUCT_NAME:rfc1034identifier}"));
plist_in_text.replace("@BUNDLEIDENTIFIER@", bundlePrefix + '.' + QLatin1String("${PRODUCT_NAME:rfc1034identifier}"));
if (!project->values("VERSION").isEmpty()) {
plist_in_text = plist_in_text.replace("@SHORT_VERSION@", project->first("VER_MAJ") + "." +
project->first("VER_MIN"));
plist_in_text.replace("@SHORT_VERSION@", project->first("VER_MAJ") + "." + project->first("VER_MIN"));
}
plist_in_text = plist_in_text.replace("@TYPEINFO@",
plist_in_text.replace("@TYPEINFO@",
(project->isEmpty("QMAKE_PKGINFO_TYPEINFO")
? QString::fromLatin1("????") : project->first("QMAKE_PKGINFO_TYPEINFO").left(4).toQString()));
QFile plist_out_file("Info.plist");
@ -1746,7 +1745,7 @@ ProjectBuilderMakefileGenerator::pbuilderVersion() const
version_plist = "/Developer/Applications/Project Builder.app/Contents/version.plist";
#endif
} else {
version_plist = version_plist.replace(QRegExp("\""), "");
version_plist.replace(QRegExp("\""), "");
}
if (ret.isEmpty()) {
QFile version_file(version_plist);

View File

@ -2280,7 +2280,7 @@ MakefileGenerator::findSubDirsSubTargets() const
ProString ofile = subdirs[subdir];
QString oname = ofile.toQString();
QString fixedSubdir = oname;
fixedSubdir = fixedSubdir.replace(QRegExp("[^a-zA-Z0-9_]"),"-");
fixedSubdir.replace(QRegExp("[^a-zA-Z0-9_]"),"-");
SubTarget *st = new SubTarget;
st->name = oname;
@ -2345,7 +2345,7 @@ MakefileGenerator::findSubDirsSubTargets() const
if(subdirs[subDep] == depends.at(depend)) {
QString subName = subdirs[subDep].toQString();
QString fixedSubDep = subName;
fixedSubDep = fixedSubDep.replace(QRegExp("[^a-zA-Z0-9_]"),"-");
fixedSubDep.replace(QRegExp("[^a-zA-Z0-9_]"),"-");
const ProKey dtkey(fixedSubDep + ".target");
if (!project->isEmpty(dtkey)) {
st->depends += project->first(dtkey);
@ -2376,7 +2376,7 @@ MakefileGenerator::findSubDirsSubTargets() const
st->target = project->first(tkey).toQString();
} else {
st->target = "sub-" + file;
st->target = st->target.replace(QRegExp("[^a-zA-Z0-9_]"),"-");
st->target.replace(QRegExp("[^a-zA-Z0-9_]"), "-");
}
}
}
@ -3146,7 +3146,7 @@ MakefileGenerator::pkgConfigFixPath(QString path) const
{
QString prefix = pkgConfigPrefix();
if(path.startsWith(prefix))
path = path.replace(prefix, "${prefix}");
path.replace(prefix, "${prefix}");
return path;
}

View File

@ -488,7 +488,7 @@ ProjectGenerator::fixPathToQmake(const QString &file)
{
QString ret = file;
if(Option::dir_sep != QLatin1String("/"))
ret = ret.replace(Option::dir_sep, QLatin1String("/"));
ret.replace(Option::dir_sep, QLatin1String("/"));
return ret;
}

View File

@ -194,13 +194,11 @@ UnixMakefileGenerator::init()
pchBaseName += project->first("QMAKE_ORIG_TARGET").toQString();
// replace place holders
pchFlags = pchFlags.replace("${QMAKE_PCH_INPUT}",
project->first("PRECOMPILED_HEADER").toQString());
pchFlags = pchFlags.replace("${QMAKE_PCH_OUTPUT_BASE}", pchBaseName);
pchFlags.replace("${QMAKE_PCH_INPUT}", project->first("PRECOMPILED_HEADER").toQString());
pchFlags.replace("${QMAKE_PCH_OUTPUT_BASE}", pchBaseName);
if (project->isActiveConfig("icc_pch_style")) {
// icc style
pchFlags = pchFlags.replace("${QMAKE_PCH_OUTPUT}",
pchBaseName + project->first("QMAKE_PCH_OUTPUT_EXT"));
pchFlags.replace("${QMAKE_PCH_OUTPUT}", pchBaseName + project->first("QMAKE_PCH_OUTPUT_EXT"));
} else {
// gcc style (including clang_pch_style)
QString headerSuffix;
@ -224,8 +222,7 @@ UnixMakefileGenerator::init()
}
if(!pchOutputFile.isEmpty()) {
pchFlags = pchFlags.replace("${QMAKE_PCH_OUTPUT}",
pchBaseName + pchOutputFile + headerSuffix);
pchFlags.replace("${QMAKE_PCH_OUTPUT}", pchBaseName + pchOutputFile + headerSuffix);
}
}

View File

@ -714,7 +714,7 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
t << destdir << "$(TARGET): " << var("PRE_TARGETDEPS")
<< " " << var("POST_TARGETDEPS") << valList(build) << "\n\t";
ar = project->first("QMAKE_AR_CMD").toQString();
ar = ar.replace("$(OBJECTS)", build.join(' '));
ar.replace("$(OBJECTS)", build.join(' '));
} else {
t << (*libit) << ": " << valList(build) << "\n\t";
ar = "$(AR) " + (*libit) + " " + build.join(' ');
@ -1075,8 +1075,8 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
<< "\n\techo \"// Automatically generated, do not modify\" > " << sourceFile
<< "\n\trm -f " << pchOutput;
pchFlags = pchFlags.replace("${QMAKE_PCH_TEMP_SOURCE}", sourceFile)
.replace("${QMAKE_PCH_TEMP_OBJECT}", objectFile);
pchFlags.replace("${QMAKE_PCH_TEMP_SOURCE}", sourceFile)
.replace("${QMAKE_PCH_TEMP_OBJECT}", objectFile);
} else {
// gcc style (including clang_pch_style)
ProString header_prefix = project->first("QMAKE_PRECOMP_PREFIX");
@ -1102,9 +1102,9 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
t << pchOutput << ": " << pchInput << " " << findDependencies(pchInput).join(" \\\n\t\t")
<< "\n\t" << mkdir_p_asstring(pchOutputDir);
}
pchFlags = pchFlags.replace("${QMAKE_PCH_INPUT}", pchInput)
.replace("${QMAKE_PCH_OUTPUT_BASE}", pchBaseName.toQString())
.replace("${QMAKE_PCH_OUTPUT}", pchOutput.toQString());
pchFlags.replace("${QMAKE_PCH_INPUT}", pchInput)
.replace("${QMAKE_PCH_OUTPUT_BASE}", pchBaseName.toQString())
.replace("${QMAKE_PCH_OUTPUT}", pchOutput.toQString());
QString compiler;
if(comps[i] == "C" || comps[i] == "OBJC" || comps[i] == "OBJCXX")

View File

@ -1693,11 +1693,11 @@ QString VcprojGenerator::fixFilename(QString ofile) const
ofile = Option::fixPathToLocalOS(ofile);
int slashfind = ofile.lastIndexOf(Option::dir_sep);
if(slashfind == -1) {
ofile = ofile.replace('-', '_');
ofile.replace('-', '_');
} else {
int hyphenfind = ofile.indexOf('-', slashfind);
while (hyphenfind != -1 && slashfind < hyphenfind) {
ofile = ofile.replace(hyphenfind, 1, '_');
ofile.replace(hyphenfind, 1, '_');
hyphenfind = ofile.indexOf('-', hyphenfind + 1);
}
}

View File

@ -530,15 +530,15 @@ Option::fixString(QString string, uchar flags)
//fix separators
if (flags & Option::FixPathToNormalSeparators) {
string = string.replace('\\', '/');
string.replace('\\', '/');
} else if (flags & Option::FixPathToLocalSeparators) {
#if defined(Q_OS_WIN32)
string = string.replace('/', '\\');
string.replace('/', '\\');
#else
string = string.replace('\\', '/');
string.replace('\\', '/');
#endif
} else if(flags & Option::FixPathToTargetSeparators) {
string = string.replace('/', Option::dir_sep).replace('\\', Option::dir_sep);
string.replace('/', Option::dir_sep).replace('\\', Option::dir_sep);
}
if ((string.startsWith("\"") && string.endsWith("\"")) ||