qmake: use QString::replace() overloaded with QLatin1String
instead of QStringLiteral, QString, const char*. Results: reduce .rodata, prevent re-creation of QString. Change-Id: Ie2e3089974c42e6733457bbe58521bccd1da3a53 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
This commit is contained in:
parent
4a251da5bb
commit
4748acbf1e
@ -1494,21 +1494,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.replace("@ICON@",
|
||||
plist_in_text.replace(QLatin1String("@ICON@"),
|
||||
(project->isEmpty("ICON") ? QString("") : project->first("ICON").toQString().section(Option::dir_sep, -1)));
|
||||
if (project->first("TEMPLATE") == "app") {
|
||||
plist_in_text.replace("@EXECUTABLE@", project->first("QMAKE_ORIG_TARGET").toQString());
|
||||
plist_in_text.replace(QLatin1String("@EXECUTABLE@"), project->first("QMAKE_ORIG_TARGET").toQString());
|
||||
} else {
|
||||
plist_in_text.replace("@LIBRARY@", project->first("QMAKE_ORIG_TARGET").toQString());
|
||||
plist_in_text.replace(QLatin1String("@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.replace("@BUNDLEIDENTIFIER@", bundlePrefix + '.' + QLatin1String("${PRODUCT_NAME:rfc1034identifier}"));
|
||||
plist_in_text.replace(QLatin1String("@BUNDLEIDENTIFIER@"), bundlePrefix + '.' + QLatin1String("${PRODUCT_NAME:rfc1034identifier}"));
|
||||
if (!project->values("VERSION").isEmpty()) {
|
||||
plist_in_text.replace("@SHORT_VERSION@", project->first("VER_MAJ") + "." + project->first("VER_MIN"));
|
||||
plist_in_text.replace(QLatin1String("@SHORT_VERSION@"), project->first("VER_MAJ") + "." + project->first("VER_MIN"));
|
||||
}
|
||||
plist_in_text.replace("@TYPEINFO@",
|
||||
plist_in_text.replace(QLatin1String("@TYPEINFO@"),
|
||||
(project->isEmpty("QMAKE_PKGINFO_TYPEINFO")
|
||||
? QString::fromLatin1("????") : project->first("QMAKE_PKGINFO_TYPEINFO").left(4).toQString()));
|
||||
QFile plist_out_file(Option::output_dir + "/Info.plist");
|
||||
@ -1711,9 +1711,9 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
|
||||
QTextStream defaultSchemeStream(&defaultSchemeFile);
|
||||
QString schemeData = defaultSchemeStream.readAll();
|
||||
|
||||
schemeData.replace("@QMAKE_ORIG_TARGET@", target);
|
||||
schemeData.replace("@TARGET_PBX_KEY@", keyFor(pbx_dir + "QMAKE_PBX_TARGET"));
|
||||
schemeData.replace("@TEST_BUNDLE_PBX_KEY@", keyFor("QMAKE_TEST_BUNDLE_REFERENCE"));
|
||||
schemeData.replace(QLatin1String("@QMAKE_ORIG_TARGET@"), target);
|
||||
schemeData.replace(QLatin1String("@TARGET_PBX_KEY@"), keyFor(pbx_dir + "QMAKE_PBX_TARGET"));
|
||||
schemeData.replace(QLatin1String("@TEST_BUNDLE_PBX_KEY@"), keyFor("QMAKE_TEST_BUNDLE_REFERENCE"));
|
||||
|
||||
QTextStream outputSchemeStream(&outputSchemeFile);
|
||||
outputSchemeStream << schemeData;
|
||||
|
@ -1132,8 +1132,8 @@ MakefileGenerator::writeObj(QTextStream &t, const char *src)
|
||||
|
||||
ProStringList::ConstIterator oit = objl.begin();
|
||||
ProStringList::ConstIterator sit = srcl.begin();
|
||||
QString stringSrc("$src");
|
||||
QString stringObj("$obj");
|
||||
QLatin1String stringSrc("$src");
|
||||
QLatin1String stringObj("$obj");
|
||||
for(;sit != srcl.end() && oit != objl.end(); ++oit, ++sit) {
|
||||
if((*sit).isEmpty())
|
||||
continue;
|
||||
@ -2282,7 +2282,7 @@ MakefileGenerator::writeHeader(QTextStream &t)
|
||||
t << "# Project: " << fileFixify(project->projectFile()) << endl;
|
||||
t << "# Template: " << var("TEMPLATE") << endl;
|
||||
if(!project->isActiveConfig("build_pass"))
|
||||
t << "# Command: " << build_args().replace("$(QMAKE)", var("QMAKE_QMAKE")) << endl;
|
||||
t << "# Command: " << build_args().replace(QLatin1String("$(QMAKE)"), var("QMAKE_QMAKE")) << endl;
|
||||
t << "#############################################################################\n";
|
||||
t << endl;
|
||||
QString ofile = Option::fixPathToTargetOS(Option::output.fileName());
|
||||
@ -3177,7 +3177,7 @@ MakefileGenerator::pkgConfigFixPath(QString path) const
|
||||
{
|
||||
QString prefix = pkgConfigPrefix();
|
||||
if(path.startsWith(prefix))
|
||||
path.replace(prefix, "${prefix}");
|
||||
path.replace(prefix, QLatin1String("${prefix}"));
|
||||
return path;
|
||||
}
|
||||
|
||||
@ -3329,7 +3329,7 @@ static QString windowsifyPath(const QString &str)
|
||||
{
|
||||
// The paths are escaped in prl files, so every slash needs to turn into two backslashes.
|
||||
// Then each backslash needs to be escaped for sed. And another level for C quoting here.
|
||||
return QString(str).replace('/', "\\\\\\\\");
|
||||
return QString(str).replace('/', QLatin1String("\\\\\\\\"));
|
||||
}
|
||||
|
||||
QString MakefileGenerator::installMetaFile(const ProKey &replace_rule, const QString &src, const QString &dst)
|
||||
|
@ -178,12 +178,12 @@ UnixMakefileGenerator::init()
|
||||
pchBaseName += project->first("QMAKE_ORIG_TARGET").toQString();
|
||||
|
||||
// replace place holders
|
||||
pchFlags.replace("${QMAKE_PCH_INPUT}",
|
||||
pchFlags.replace(QLatin1String("${QMAKE_PCH_INPUT}"),
|
||||
escapeFilePath(project->first("PRECOMPILED_HEADER").toQString()));
|
||||
pchFlags.replace("${QMAKE_PCH_OUTPUT_BASE}", escapeFilePath(pchBaseName));
|
||||
pchFlags.replace(QLatin1String("${QMAKE_PCH_OUTPUT_BASE}"), escapeFilePath(pchBaseName));
|
||||
if (project->isActiveConfig("icc_pch_style")) {
|
||||
// icc style
|
||||
pchFlags.replace("${QMAKE_PCH_OUTPUT}",
|
||||
pchFlags.replace(QLatin1String("${QMAKE_PCH_OUTPUT}"),
|
||||
escapeFilePath(pchBaseName + project->first("QMAKE_PCH_OUTPUT_EXT")));
|
||||
} else {
|
||||
// gcc style (including clang_pch_style)
|
||||
@ -197,7 +197,7 @@ UnixMakefileGenerator::init()
|
||||
|
||||
ProString language = project->first(ProKey("QMAKE_LANGUAGE_" + compiler));
|
||||
if (!language.isEmpty()) {
|
||||
pchFlags.replace("${QMAKE_PCH_OUTPUT}",
|
||||
pchFlags.replace(QLatin1String("${QMAKE_PCH_OUTPUT}"),
|
||||
escapeFilePath(pchBaseName + language + headerSuffix));
|
||||
}
|
||||
}
|
||||
|
@ -536,7 +536,7 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
|
||||
<< "ld -r -o " << incr_target_dir_f << ' ' << link_deps << endl;
|
||||
//communicated below
|
||||
ProStringList &cmd = project->values("QMAKE_LINK_SHLIB_CMD");
|
||||
cmd[0] = cmd.at(0).toQString().replace("$(OBJECTS) ", "$(INCREMENTAL_OBJECTS)"); //ick
|
||||
cmd[0] = cmd.at(0).toQString().replace(QLatin1String("$(OBJECTS) "), QLatin1String("$(INCREMENTAL_OBJECTS)")); //ick
|
||||
cmd.append(incr_target_dir_f);
|
||||
deps.prepend(incr_target_dir_d + ' ');
|
||||
incr_deps = "$(INCREMENTAL_OBJECTS)";
|
||||
@ -704,7 +704,7 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
|
||||
t << destdir_d << "$(TARGET): " << depVar("PRE_TARGETDEPS")
|
||||
<< ' ' << depVar("POST_TARGETDEPS") << valList(escapeDependencyPaths(build)) << "\n\t";
|
||||
ar = project->first("QMAKE_AR_CMD").toQString();
|
||||
ar.replace("$(OBJECTS)", escapeFilePaths(build).join(' '));
|
||||
ar.replace(QLatin1String("$(OBJECTS)"), escapeFilePaths(build).join(' '));
|
||||
} else {
|
||||
t << destdir_d << escapeDependencyPath(*libit) << ": "
|
||||
<< valList(escapeDependencyPaths(build)) << "\n\t";
|
||||
@ -1083,8 +1083,8 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
|
||||
<< "\n\techo \"// Automatically generated, do not modify\" > " << sourceFile_f
|
||||
<< "\n\trm -f " << escapeFilePath(pchOutput);
|
||||
|
||||
pchFlags.replace("${QMAKE_PCH_TEMP_SOURCE}", sourceFile_f)
|
||||
.replace("${QMAKE_PCH_TEMP_OBJECT}", escapeFilePath(objectFile));
|
||||
pchFlags.replace(QLatin1String("${QMAKE_PCH_TEMP_SOURCE}"), sourceFile_f)
|
||||
.replace(QLatin1String("${QMAKE_PCH_TEMP_OBJECT}"), escapeFilePath(objectFile));
|
||||
} else {
|
||||
// gcc style (including clang_pch_style)
|
||||
ProString header_prefix = project->first("QMAKE_PRECOMP_PREFIX");
|
||||
@ -1103,9 +1103,9 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
|
||||
<< escapeDependencyPaths(findDependencies(pchInput)).join(" \\\n\t\t")
|
||||
<< "\n\t" << mkdir_p_asstring(pchOutputDir);
|
||||
}
|
||||
pchFlags.replace("${QMAKE_PCH_INPUT}", escapeFilePath(pchInput))
|
||||
.replace("${QMAKE_PCH_OUTPUT_BASE}", escapeFilePath(pchBaseName.toQString()))
|
||||
.replace("${QMAKE_PCH_OUTPUT}", escapeFilePath(pchOutput.toQString()));
|
||||
pchFlags.replace(QLatin1String("${QMAKE_PCH_INPUT}"), escapeFilePath(pchInput))
|
||||
.replace(QLatin1String("${QMAKE_PCH_OUTPUT_BASE}"), escapeFilePath(pchBaseName.toQString()))
|
||||
.replace(QLatin1String("${QMAKE_PCH_OUTPUT}"), escapeFilePath(pchOutput.toQString()));
|
||||
|
||||
QString compilerExecutable;
|
||||
if (compiler == "C" || compiler == "OBJC")
|
||||
@ -1151,7 +1151,7 @@ void UnixMakefileGenerator::init2()
|
||||
|
||||
ProStringList &ar_cmd = project->values("QMAKE_AR_CMD");
|
||||
if (!ar_cmd.isEmpty())
|
||||
ar_cmd[0] = ar_cmd.at(0).toQString().replace("(TARGET)","(TARGETA)");
|
||||
ar_cmd[0] = ar_cmd.at(0).toQString().replace(QLatin1String("(TARGET)"), QLatin1String("(TARGETA)"));
|
||||
else
|
||||
ar_cmd.append("$(AR) $(TARGETA) $(OBJECTS)");
|
||||
if (!project->isEmpty("QMAKE_BUNDLE")) {
|
||||
|
@ -147,7 +147,7 @@ bool CeSdkHandler::parseMsBuildFile(QFile *file, CeSdkInfo *info)
|
||||
QSettings sdkRootPathRegistry(regString, QSettings::NativeFormat);
|
||||
const QString erg = sdkRootPathRegistry.value(QStringLiteral(".")).toString();
|
||||
const QString fullSdkRootPath = erg + sdkRootPath.mid(endIndex + 1);
|
||||
const QString rootString = QStringLiteral("$(SdkRootPath)");
|
||||
const QLatin1String rootString("$(SdkRootPath)");
|
||||
|
||||
includePath = includePath.replace(rootString, fullSdkRootPath);
|
||||
libraryPath = libraryPath.replace(rootString, fullSdkRootPath);
|
||||
|
@ -51,7 +51,7 @@ QString MingwMakefileGenerator::escapeDependencyPath(const QString &path) const
|
||||
{
|
||||
QString ret = path;
|
||||
ret.replace('\\', "/"); // ### this shouldn't be here
|
||||
ret.replace(' ', "\\ ");
|
||||
ret.replace(' ', QLatin1String("\\ "));
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -328,7 +328,7 @@ static QString vcxCommandSeparator()
|
||||
static QString unquote(const QString &value)
|
||||
{
|
||||
QString result = value;
|
||||
result.replace(QStringLiteral("\\\""), QStringLiteral("\""));
|
||||
result.replace(QLatin1String("\\\""), QLatin1String("\""));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,7 @@ static QString nmakePathList(const QStringList &list)
|
||||
pathList.append(QDir::cleanPath(path));
|
||||
|
||||
return QDir::toNativeSeparators(pathList.join(QLatin1Char(';')))
|
||||
.replace('#', QStringLiteral("^#")).replace('$', QStringLiteral("$$"));
|
||||
.replace('#', QLatin1String("^#")).replace('$', QLatin1String("$$"));
|
||||
}
|
||||
|
||||
NmakeMakefileGenerator::NmakeMakefileGenerator() : Win32MakefileGenerator(), usePCH(false)
|
||||
@ -330,7 +330,7 @@ QString NmakeMakefileGenerator::var(const ProKey &value) const
|
||||
QString precompRule = QString("-c -FI%1 -Yu%2 -Fp%3")
|
||||
.arg(precompH_f, precompH_f, escapeFilePath(precompPch));
|
||||
QString p = MakefileGenerator::var(value);
|
||||
p.replace("-c", precompRule);
|
||||
p.replace(QLatin1String("-c"), precompRule);
|
||||
// Cannot use -Gm with -FI & -Yu, as this gives an
|
||||
// internal compiler error, on the newer compilers
|
||||
// ### work-around for a VS 2003 bug. Move to some prf file or remove completely.
|
||||
|
@ -704,12 +704,12 @@ void VcprojGenerator::writeSubDirs(QTextStream &t)
|
||||
}
|
||||
QString slnConf = _slnSolutionConf;
|
||||
if (!project->isEmpty("VCPROJ_ARCH")) {
|
||||
slnConf.replace(QString("|Win32"), "|" + project->first("VCPROJ_ARCH"));
|
||||
slnConf.replace(QLatin1String("|Win32"), "|" + project->first("VCPROJ_ARCH"));
|
||||
} else if (!project->isEmpty("CE_SDK") && !project->isEmpty("CE_ARCH")) {
|
||||
QString slnPlatform = QString("|") + project->values("CE_SDK").join(' ') + " (" + project->first("CE_ARCH") + ")";
|
||||
slnConf.replace(QString("|Win32"), slnPlatform);
|
||||
slnConf.replace(QLatin1String("|Win32"), slnPlatform);
|
||||
} else if (is64Bit) {
|
||||
slnConf.replace(QString("|Win32"), "|x64");
|
||||
slnConf.replace(QLatin1String("|Win32"), QLatin1String("|x64"));
|
||||
}
|
||||
t << slnConf;
|
||||
|
||||
@ -1706,12 +1706,12 @@ QString VcprojGenerator::replaceExtraCompilerVariables(
|
||||
if(defines.isEmpty())
|
||||
defines.append(varGlue("PRL_EXPORT_DEFINES"," -D"," -D","") +
|
||||
varGlue("DEFINES"," -D"," -D",""));
|
||||
ret.replace("$(DEFINES)", defines.first().toQString());
|
||||
ret.replace(QLatin1String("$(DEFINES)"), defines.first().toQString());
|
||||
|
||||
ProStringList &incpath = project->values("VCPROJ_MAKEFILE_INCPATH");
|
||||
if(incpath.isEmpty() && !this->var("MSVCPROJ_INCPATH").isEmpty())
|
||||
incpath.append(this->var("MSVCPROJ_INCPATH"));
|
||||
ret.replace("$(INCPATH)", incpath.join(' '));
|
||||
ret.replace(QLatin1String("$(INCPATH)"), incpath.join(' '));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -401,7 +401,7 @@ void Win32MakefileGenerator::processRcFileVar()
|
||||
project->values("RC_FILE").first() = fi.absoluteFilePath();
|
||||
}
|
||||
|
||||
resFile.replace(".rc", Option::res_ext);
|
||||
resFile.replace(QLatin1String(".rc"), Option::res_ext);
|
||||
project->values("RES_FILE").prepend(fileInfo(resFile).fileName());
|
||||
QString resDestDir;
|
||||
if (project->isActiveConfig("staticlib"))
|
||||
@ -771,8 +771,8 @@ QString Win32MakefileGenerator::escapeFilePath(const QString &path) const
|
||||
QString Win32MakefileGenerator::cQuoted(const QString &str)
|
||||
{
|
||||
QString ret = str;
|
||||
ret.replace(QLatin1Char('\\'), QStringLiteral("\\\\"));
|
||||
ret.replace(QLatin1Char('"'), QStringLiteral("\\\""));
|
||||
ret.replace(QLatin1Char('\\'), QLatin1String("\\\\"));
|
||||
ret.replace(QLatin1Char('"'), QLatin1String("\\\""));
|
||||
ret.prepend(QLatin1Char('"'));
|
||||
ret.append(QLatin1Char('"'));
|
||||
return ret;
|
||||
|
@ -140,11 +140,11 @@ QString XmlOutput::doConversion(const QString &text)
|
||||
}
|
||||
|
||||
if (conversion == XMLConversion) {
|
||||
output.replace('\"', """);
|
||||
output.replace('\'', "'");
|
||||
output.replace('\"', QLatin1String("""));
|
||||
output.replace('\'', QLatin1String("'"));
|
||||
} else if (conversion == EscapeConversion) {
|
||||
output.replace('\"', "\\\"");
|
||||
output.replace('\'', "\\\'");
|
||||
output.replace('\"', QLatin1String("\\\""));
|
||||
output.replace('\'', QLatin1String("\\\'"));
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
@ -130,7 +130,7 @@ static int doSed(int argc, char **argv)
|
||||
SedSubst subst;
|
||||
subst.from = QRegExp(phases.at(0), matchcase);
|
||||
subst.to = phases.at(1);
|
||||
subst.to.replace("\\\\", "\\"); // QString::replace(rx, sub) groks \1, but not \\.
|
||||
subst.to.replace(QLatin1String("\\\\"), QLatin1String("\\")); // QString::replace(rx, sub) groks \1, but not \\.
|
||||
substs << subst;
|
||||
}
|
||||
} else if (argv[i][0] == '-' && argv[i][1] != 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user