Commit a36d587c authored by Denis Mingulov's avatar Denis Mingulov Committed by hjk

Fix non-needed usage of QString's fromLocal8Bit() and fromUtf8()

QString::fromLocal8Bit() and QString::fromUtf8() are much more slower
than an obvious QString::fromLatin1() and QLatin1String(), so this
commit changes some places where these functions are really not
needed.

QString::fromLatin1() is used in case if QString object is used
immediately (something like QString::fromLatin1().arg()),
QLatin1String is used otherwise like in other places (for example,
QPixmap(QLatin1String("..."))) - to allow to use default QString
constructor and work with QT_NO_CAST_FROM_ASCII.

Change-Id: Ib6eb1c61e9cb35c7c5b7569fea77c5e41d32621a
Reviewed-by: default avatarhjk <qthjk@ovi.com>
parent 2f27c73c
......@@ -175,7 +175,7 @@ public:
}
QString name(){
return QString::fromUtf8("AvahiZeroConfLib@%1").arg(size_t(this), 0, 16);
return QString::fromLatin1("AvahiZeroConfLib@%1").arg(size_t(this), 0, 16);
}
// bool tryStartDaemon();
......
......@@ -156,7 +156,7 @@ public:
}
QString name(){
return QString::fromUtf8("DnsSdZeroConfLib@%1").arg(size_t(this), 0, 16);
return QString::fromLatin1("DnsSdZeroConfLib@%1").arg(size_t(this), 0, 16);
}
// bool tryStartDaemon();
......
......@@ -72,7 +72,7 @@ public:
QString name()
{
return QString::fromUtf8("EmbeddedZeroConfLib@%1").arg(size_t(this), 0, 16);
return QString::fromLatin1("EmbeddedZeroConfLib@%1").arg(size_t(this), 0, 16);
}
bool tryStartDaemon()
......
......@@ -1743,7 +1743,7 @@ bool ZConfLib::tryStartDaemon()
}
QString ZConfLib::name(){
return QString::fromUtf8("ZeroConfLib@%1").arg(size_t(this), 0, 16);
return QString::fromLatin1("ZeroConfLib@%1").arg(size_t(this), 0, 16);
}
ZConfLib::ZConfLib(ZConfLib::Ptr f) : fallbackLib(f), m_isOk(true)
......
......@@ -320,7 +320,7 @@ void FancyToolButton::actionChanged()
FancyActionBar::FancyActionBar(QWidget *parent)
: QWidget(parent)
{
setObjectName(QString::fromUtf8("actionbar"));
setObjectName(QLatin1String("actionbar"));
m_actionsLayout = new QVBoxLayout;
QVBoxLayout *spacerLayout = new QVBoxLayout;
spacerLayout->addLayout(m_actionsLayout);
......
......@@ -41,7 +41,7 @@ ColumnIndicatorTextEdit::ColumnIndicatorTextEdit(QWidget *parent) :
QTextEdit(parent), m_columnIndicator(0)
{
QFont font;
font.setFamily(QString::fromUtf8("Courier New"));
font.setFamily(QLatin1String("Courier New"));
setFont(font);
setReadOnly(true);
QSizePolicy sizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
......@@ -50,7 +50,7 @@ ColumnIndicatorTextEdit::ColumnIndicatorTextEdit(QWidget *parent) :
int cmx = 0, cmy = 0, cmw = 0, cmh = 0;
getContentsMargins(&cmx, &cmy, &cmw, &cmh);
m_columnIndicator = QFontMetrics(font).width(QLatin1Char('W')) * 100 + cmx + 1;
m_columnIndicatorFont.setFamily(QString::fromUtf8("Times"));
m_columnIndicatorFont.setFamily(QLatin1String("Times"));
m_columnIndicatorFont.setPointSizeF(7.0);
}
......
......@@ -100,7 +100,7 @@ private:
const QString makeExpr(const QStringList &exprs) const
{
Q_ASSERT(exprs.size() == 1);
return QString::fromLocal8Bit("%1()").arg(exprs.first());
return QString::fromLatin1("%1()").arg(exprs.first());
}
};
......@@ -112,7 +112,7 @@ private:
const QString makeExpr(const QStringList &exprs) const
{
Q_ASSERT(exprs.size() == 1);
return QString::fromLocal8Bit("%1(%2)").
return QString::fromLatin1("%1(%2)").
arg(repr).arg(exprs.first());
}
};
......@@ -125,7 +125,7 @@ private:
virtual const QString makeExpr(const QStringList &exprs) const
{
Q_ASSERT(exprs.size() == 2);
return QString::fromLocal8Bit("%1 %2 %3").
return QString::fromLatin1("%1 %2 %3").
arg(exprs.first()).arg(repr).arg(exprs.at(1));
}
OpType type() const { return BinaryOp; }
......@@ -142,7 +142,7 @@ private:
const QString makeExpr(const QStringList &exprs) const
{
Q_ASSERT(exprs.size() == 2);
return QString::fromLocal8Bit("new %1[%2]").
return QString::fromLatin1("new %1[%2]").
arg(exprs.first()).arg(exprs.at(1));
}
};
......@@ -170,7 +170,7 @@ private:
const QString makeExpr(const QStringList &exprs) const
{
Q_ASSERT(exprs.size() == 2);
return QString::fromLocal8Bit("%1[%2]").
return QString::fromLatin1("%1[%2]").
arg(exprs.first()).arg(exprs.at(1));
}
};
......@@ -186,7 +186,7 @@ private:
virtual const QString makeExpr(const QStringList &exprs) const
{
Q_ASSERT(exprs.size() == 3);
return QString::fromLocal8Bit("%1 ? %2 : %3").
return QString::fromLatin1("%1 ? %2 : %3").
arg(exprs.first()).arg(exprs.at(1)).arg(exprs.at(2));
}
OpType type() const { return TernaryOp; }
......@@ -893,10 +893,10 @@ const QString NameDemanglerPrivate::parseExpression()
expr += QLatin1String(")");
} else if (str == QLatin1String("st")) {
advance(2);
expr = QString::fromLocal8Bit("sizeof(%1)").arg(parseType());
expr = QString::fromLatin1("sizeof(%1)").arg(parseType());
} else if (str == QLatin1String("at")) {
advance(2);
expr = QString::fromLocal8Bit("alignof(%1)").arg(parseType());
expr = QString::fromLatin1("alignof(%1)").arg(parseType());
} else if (str == QLatin1String("sr")) { // TODO: Which syntax to use here?
advance(2);
expr = parseType();
......@@ -1369,7 +1369,7 @@ const QString NameDemanglerPrivate::parseFunctionType()
}
}
if (!retTypeIsFuncPtr)
funcType = QString::fromLocal8Bit("%1 %2").
funcType = QString::fromLatin1("%1 %2").
arg(returnType).arg(argList);
}
}
......@@ -1507,7 +1507,7 @@ const NameDemanglerPrivate::Operator &NameDemanglerPrivate::parseOperatorName()
static UnaryOperator castOp(QLatin1String("cv"),
QLatin1String(""));
QString type = parseType();
castOp.repr = QString::fromLocal8Bit("(%1)").arg(type);
castOp.repr = QString::fromLatin1("(%1)").arg(type);
op = &castOp;
} else {
op = ops.value(id);
......@@ -1549,7 +1549,7 @@ const QString NameDemanglerPrivate::parseArrayType()
if (!parseError && advance() != '_')
error(QString::fromLatin1("Invalid array-type"));
if (!parseError)
type = QString::fromLocal8Bit("%1[%2]").
type = QString::fromLatin1("%1[%2]").
arg(parseType()).arg(dimension);
}
......@@ -1575,10 +1575,10 @@ const QString NameDemanglerPrivate::parsePointerToMemberType()
int parenIndex = memberType.indexOf('(');
QString returnType = memberType.left(parenIndex);
memberType.remove(0, parenIndex);
type = QString::fromLocal8Bit("%1(%2::*)%3").
type = QString::fromLatin1("%1(%2::*)%3").
arg(returnType).arg(classType).arg(memberType);
} else {
type = QString::fromLocal8Bit("%1 %2::*").
type = QString::fromLatin1("%1 %2::*").
arg(memberType).arg(classType);
}
}
......@@ -1703,19 +1703,19 @@ const QString NameDemanglerPrivate::parseSpecialName()
QString str = readAhead(2);
if (str == QLatin1String("TV")) {
advance(2);
name = QString::fromLocal8Bit("[virtual table of %1]").arg(parseType());
name = QString::fromLatin1("[virtual table of %1]").arg(parseType());
} else if (str == QLatin1String("TT")) {
advance(2);
name = QString::fromLocal8Bit("[VTT struct of %1]").arg(parseType());
name = QString::fromLatin1("[VTT struct of %1]").arg(parseType());
} else if (str == QLatin1String("TI")) {
advance(2);
name = QString::fromLocal8Bit("typeid(%1)").arg(parseType());
name = QString::fromLatin1("typeid(%1)").arg(parseType());
} else if (str == QLatin1String("TS")) {
advance(2);
name = QString::fromLocal8Bit("typeid(%1).name()").arg(parseType());
name = QString::fromLatin1("typeid(%1).name()").arg(parseType());
} else if (str == QLatin1String("GV")) {
advance(2);
name = QString::fromLocal8Bit("[guard variable of %1]").
name = QString::fromLatin1("[guard variable of %1]").
arg(parseName());
} else if (str == QLatin1String("Tc")) {
advance(2);
......@@ -2178,7 +2178,7 @@ void NameDemanglerPrivate::insertQualifier(QString &type,
if (qualifier == QLatin1String("*")
|| qualifier == QLatin1String("&")) {
insertionPos = funcAnchor;
insertionString = QString::fromLocal8Bit("(%1)").arg(qualifier);
insertionString = QString::fromLatin1("(%1)").arg(qualifier);
} else {
insertionPos = type.size(); // Qualifier for pointer to member.
}
......
......@@ -206,7 +206,7 @@ QString MaemoDeployConfigurationWidget::remoteIconFilePath(const DeployableFiles
QString MaemoDeployConfigurationWidget::remoteIconDir() const
{
return QString::fromLocal8Bit("/usr/share/icons/hicolor/%1x%1/apps")
return QString::fromLatin1("/usr/share/icons/hicolor/%1x%1/apps")
.arg(MaemoGlobal::applicationIconSize(deployConfiguration()->supportedOsType()));
}
......
......@@ -132,7 +132,7 @@ void MaemoRemoteMounter::unmount()
const QString remoteSudo = MaemoGlobal::remoteSudo(m_devConf->osType(),
m_connection->connectionParameters().userName);
for (int i = 0; i < m_mountSpecs.count(); ++i) {
remoteCall += QString::fromLocal8Bit("%1 umount %2 && %1 rmdir %2;")
remoteCall += QString::fromLatin1("%1 umount %2 && %1 rmdir %2;")
.arg(remoteSudo, m_mountSpecs.at(i).mountSpec.remoteMountPoint);
}
......@@ -207,12 +207,12 @@ void MaemoRemoteMounter::startUtfsClients()
const QString remoteSudo
= MaemoGlobal::remoteSudo(m_devConf->osType(), userName);
const MaemoMountSpecification &mountSpec = mountInfo.mountSpec;
const QString mkdir = QString::fromLocal8Bit("%1 mkdir -p %2")
const QString mkdir = QString::fromLatin1("%1 mkdir -p %2")
.arg(remoteSudo, mountSpec.remoteMountPoint);
const QString chmod = QString::fromLocal8Bit("%1 chmod a+r+w+x %2")
const QString chmod = QString::fromLatin1("%1 chmod a+r+w+x %2")
.arg(remoteSudo, mountSpec.remoteMountPoint);
QString utfsClient
= QString::fromLocal8Bit("%1 -l %2 -r %2 -b %2 %4 -o nonempty")
= QString::fromLatin1("%1 -l %2 -r %2 -b %2 %4 -o nonempty")
.arg(utfsClientOnDevice()).arg(mountInfo.remotePort)
.arg(mountSpec.remoteMountPoint);
if (mountInfo.mountAsRoot) {
......
......@@ -128,7 +128,7 @@ QString MaemoRunConfiguration::commandPrefix() const
if (deviceConfig()->osType() == QLatin1String(MeeGoOsType))
prefix += QLatin1String("DISPLAY=:0.0 ");
return QString::fromLocal8Bit("%1 %2").arg(prefix, userEnvironmentChangesAsString());
return QString::fromLatin1("%1 %2").arg(prefix, userEnvironmentChangesAsString());
}
PortList MaemoRunConfiguration::freePorts() const
......
......@@ -456,7 +456,7 @@ bool AbstractDebBasedQt4MaemoTarget::setProjectVersionInternal(const QString &ve
.arg(utcOffsetMinutes, 2, 10, QLatin1Char('0'));
const QString maintainerLine = content.mid(maintainerOffset, eolOffset - maintainerOffset + 1)
.replace(QRegExp(QLatin1String("> [^\\n]*\n")),
QString::fromLocal8Bit("> %1").arg(dateString));
QString::fromLatin1("> %1").arg(dateString));
QString versionLine = content.left(content.indexOf(QLatin1Char('\n')))
.replace(QRegExp(QLatin1String("\\([a-zA-Z0-9_\\.]+\\)")),
QLatin1Char('(') + version + QLatin1Char(')'));
......
......@@ -115,9 +115,9 @@ void RemoteLinuxQmlProfilerRunner::getPorts()
QString arguments = runner()->arguments();
if (!arguments.isEmpty())
arguments.append(QLatin1Char(' '));
arguments.append(QString(QLatin1String("-qmljsdebugger=port:%1,block")).arg(m_port));
arguments.append(QString::fromLatin1("-qmljsdebugger=port:%1,block").arg(m_port));
runner()->startExecution(QString::fromLocal8Bit("%1 %2 %3")
runner()->startExecution(QString::fromLatin1("%1 %2 %3")
.arg(runner()->commandPrefix())
.arg(runner()->remoteExecutable())
.arg(arguments).toUtf8());
......
......@@ -201,7 +201,7 @@ Qt4RunConfigurationWidget::Qt4RunConfigurationWidget(Qt4RunConfiguration *qt4Run
QHBoxLayout *hl = new QHBoxLayout();
hl->addStretch();
m_disabledIcon = new QLabel(this);
m_disabledIcon->setPixmap(QPixmap(QString::fromUtf8(":/projectexplorer/images/compile_warning.png")));
m_disabledIcon->setPixmap(QPixmap(QLatin1String(":/projectexplorer/images/compile_warning.png")));
hl->addWidget(m_disabledIcon);
m_disabledReason = new QLabel(this);
m_disabledReason->setVisible(false);
......
......@@ -62,7 +62,7 @@ S60DeviceRunConfigurationWidget::S60DeviceRunConfigurationWidget(
QHBoxLayout *hl = new QHBoxLayout();
hl->addStretch();
m_disabledIcon = new QLabel(this);
m_disabledIcon->setPixmap(QPixmap(QString::fromUtf8(":/projectexplorer/images/compile_warning.png")));
m_disabledIcon->setPixmap(QPixmap(QLatin1String(":/projectexplorer/images/compile_warning.png")));
hl->addWidget(m_disabledIcon);
m_disabledReason = new QLabel(this);
m_disabledReason->setVisible(false);
......
......@@ -222,7 +222,7 @@ S60EmulatorRunConfigurationWidget::S60EmulatorRunConfigurationWidget(S60Emulator
QHBoxLayout *hl = new QHBoxLayout();
hl->addStretch();
m_disabledIcon = new QLabel(this);
m_disabledIcon->setPixmap(QPixmap(QString::fromUtf8(":/projectexplorer/images/compile_warning.png")));
m_disabledIcon->setPixmap(QPixmap(QLatin1String(":/projectexplorer/images/compile_warning.png")));
hl->addWidget(m_disabledIcon);
m_disabledReason = new QLabel(this);
m_disabledReason->setVisible(false);
......
......@@ -111,7 +111,7 @@ void PublicKeyDeploymentDialog::handleDeploymentFinished(const QString &errorMsg
buttonText = errorMsg;
textColor = "red";
}
setLabelText(QString::fromLocal8Bit("<font color=\"%1\">%2</font>").arg(textColor, buttonText));
setLabelText(QString::fromLatin1("<font color=\"%1\">%2</font>").arg(textColor, buttonText));
setCancelButtonText(tr("Close"));
}
......
......@@ -460,7 +460,7 @@ void AbstractRemoteLinuxApplicationRunner::handlePostRunCleanupDone()
QString AbstractRemoteLinuxApplicationRunner::killApplicationCommandLine() const
{
return QString::fromLocal8Bit("cd /proc; for pid in `ls -d [0123456789]*`; "
return QString::fromLatin1("cd /proc; for pid in `ls -d [0123456789]*`; "
"do "
"if [ \"`readlink /proc/$pid/exe`\" = \"%1\" ]; then "
" kill $pid; sleep 1; kill -9 $pid; "
......
......@@ -201,13 +201,13 @@ void AbstractRemoteLinuxDebugSupport::startExecution()
const QString &remoteExe = runner()->remoteExecutable();
QString args = runner()->arguments();
if (d->qmlDebugging) {
args += QString(QLatin1String(" -qmljsdebugger=port:%1,block"))
args += QString::fromLatin1(" -qmljsdebugger=port:%1,block")
.arg(d->qmlPort);
}
const QString remoteCommandLine = (d->qmlDebugging && !d->cppDebugging)
? QString::fromLocal8Bit("%1 %2 %3").arg(runner()->commandPrefix()).arg(remoteExe).arg(args)
: QString::fromLocal8Bit("%1 gdbserver :%2 %3 %4").arg(runner()->commandPrefix())
? QString::fromLatin1("%1 %2 %3").arg(runner()->commandPrefix()).arg(remoteExe).arg(args)
: QString::fromLatin1("%1 gdbserver :%2 %3 %4").arg(runner()->commandPrefix())
.arg(d->gdbServerPort).arg(remoteExe).arg(args);
connect(runner(), SIGNAL(remoteProcessFinished(qint64)),
SLOT(handleRemoteProcessFinished(qint64)));
......
......@@ -237,7 +237,7 @@ GenericRemoteLinuxProcessList::GenericRemoteLinuxProcessList(const LinuxDeviceCo
QString GenericRemoteLinuxProcessList::listProcessesCommandLine() const
{
return QString::fromLocal8Bit("for dir in `ls -d /proc/[0123456789]*`; "
return QString::fromLatin1("for dir in `ls -d /proc/[0123456789]*`; "
"do printf \"${dir}%1\";cat $dir/cmdline; printf '%1';cat $dir/stat;printf '\\n'; done")
.arg(Delimiter);
}
......
......@@ -278,7 +278,7 @@ QString RemoteLinuxRunConfiguration::environmentPreparationCommand() const
const QStringList filesToSource = QStringList() << QLatin1String("/etc/profile")
<< QLatin1String("$HOME/.profile");
foreach (const QString &filePath, filesToSource)
command += QString::fromLocal8Bit("test -f %1 && source %1;").arg(filePath);
command += QString::fromLatin1("test -f %1 && source %1;").arg(filePath);
if (!workingDirectory().isEmpty())
command += QLatin1String("cd ") + workingDirectory();
else
......@@ -288,7 +288,7 @@ QString RemoteLinuxRunConfiguration::environmentPreparationCommand() const
QString RemoteLinuxRunConfiguration::commandPrefix() const
{
return QString::fromLocal8Bit("%1; DISPLAY=:0.0 %2")
return QString::fromLatin1("%1; DISPLAY=:0.0 %2")
.arg(environmentPreparationCommand(), userEnvironmentChangesAsString());
}
......
......@@ -136,7 +136,7 @@ void RemoteLinuxRunConfigurationWidget::addDisabledLabel(QVBoxLayout *topLayout)
{
QHBoxLayout * const hl = new QHBoxLayout;
hl->addStretch();
d->disabledIcon.setPixmap(QPixmap(QString::fromUtf8(":/projectexplorer/images/compile_warning.png")));
d->disabledIcon.setPixmap(QPixmap(QLatin1String(":/projectexplorer/images/compile_warning.png")));
hl->addWidget(&d->disabledIcon);
d->disabledReason.setVisible(false);
hl->addWidget(&d->disabledReason);
......
......@@ -91,7 +91,7 @@ void AbstractRemoteLinuxRunControl::handleSshError(const QString &error)
void AbstractRemoteLinuxRunControl::startExecution()
{
appendMessage(tr("Starting remote process ...\n"), Utils::NormalMessageFormat);
runner()->startExecution(QString::fromLocal8Bit("%1 %2 %3")
runner()->startExecution(QString::fromLatin1("%1 %2 %3")
.arg(runner()->commandPrefix())
.arg(runner()->remoteExecutable())
.arg(runner()->arguments()).toUtf8());
......
......@@ -93,7 +93,7 @@ void RemoteLinuxUsedPortsGatherer::start(const Utils::SshConnection::Ptr &connec
procFilePath = QLatin1String("/proc/net/tcp6");
addressLength = 32;
}
const QString command = QString::fromLocal8Bit("sed "
const QString command = QString::fromLatin1("sed "
"'s/.*: [[:xdigit:]]\\{%1\\}:\\([[:xdigit:]]\\{4\\}\\).*/\\1/g' %2")
.arg(addressLength).arg(procFilePath);
......
......@@ -142,7 +142,7 @@ SuppressionDialog::SuppressionDialog(MemcheckErrorView *view, const QList<Error>
suppressionsLabel->setBuddy(m_suppressionEdit);
QFont font;
font.setFamily(QString::fromUtf8("Monospace"));
font.setFamily(QLatin1String("Monospace"));
m_suppressionEdit->setFont(font);
m_buttonBox = new QDialogButtonBox(this);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment