Commit 8b0d849a authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Orgad Shaneh

ExtraCompiler: Store contents as Utf8

Avoid conversions when they're not needed.

Change-Id: I7e996bc6e87be4327d75f0d743ff2de38d6ccc32
Reviewed-by: default avatarUlf Hermann <ulf.hermann@theqtcompany.com>
parent 97414e65
......@@ -103,7 +103,7 @@ void GeneratedCodeModelSupport::init() const
QByteArray GeneratedCodeModelSupport::contents() const
{
return m_generator->content(m_generatedFileName).toUtf8();
return m_generator->content(m_generatedFileName);
}
QString GeneratedCodeModelSupport::fileName() const
......
......@@ -52,7 +52,7 @@ public:
const Project *project;
Utils::FileName source;
Utils::FileNameList targets;
QVector<QString> contents;
QVector<QByteArray> contents;
QList<Task> issues;
QDateTime compileTime;
Core::IEditor *lastEditor = 0;
......@@ -117,7 +117,7 @@ ExtraCompiler::ExtraCompiler(const Project *project, const Utils::FileName &sour
QFile file(target.toString());
if (file.open(QFile::ReadOnly | QFile::Text))
setContent(target, QTextStream(&file).readAll());
setContent(target, file.readAll());
}
if (d->dirty) {
......@@ -146,13 +146,13 @@ Utils::FileName ExtraCompiler::source() const
return d->source;
}
QString ExtraCompiler::content(const Utils::FileName &file) const
QByteArray ExtraCompiler::content(const Utils::FileName &file) const
{
for (int i = 0; i < d->targets.length(); ++i) {
if (d->targets[i] == file)
return d->contents[i];
}
return QString();
return QByteArray();
}
Utils::FileNameList ExtraCompiler::targets() const
......@@ -190,9 +190,8 @@ void ExtraCompiler::onTargetsBuilt(Project *project)
QFile file(target.toString());
if (file.open(QFile::ReadOnly | QFile::Text)) {
QTextStream stream(&file);
d->compileTime = generateTime;
setContent(target, stream.readAll());
setContent(target, file.readAll());
}
}
}
......@@ -334,7 +333,7 @@ void ExtraCompilerPrivate::updateIssues()
widget->setExtraSelections(TextEditor::TextEditorWidget::CodeWarningsSelection, selections);
}
void ExtraCompiler::setContent(const Utils::FileName &file, const QString &contents)
void ExtraCompiler::setContent(const Utils::FileName &file, const QByteArray &contents)
{
for (int i = 0; i < d->targets.length(); ++i) {
if (d->targets[i] == file) {
......
......@@ -50,8 +50,8 @@ public:
// You can set the contents from the outside. This is done if the file has been (re)created by
// the regular build process.
void setContent(const Utils::FileName &file, const QString &content);
QString content(const Utils::FileName &file) const;
void setContent(const Utils::FileName &file, const QByteArray &content);
QByteArray content(const Utils::FileName &file) const;
Utils::FileNameList targets() const;
......
......@@ -76,7 +76,7 @@ void QScxmlcGenerator::finishProcess()
QFile generated(m_tmpdir.path() + QLatin1Char('/') + target.fileName());
if (!generated.open(QIODevice::ReadOnly))
continue;
setContent(target, QString::fromUtf8(generated.readAll()));
setContent(target, generated.readAll());
}
}
......
......@@ -62,7 +62,7 @@ void UicGenerator::finishProcess()
// As far as I can discover in the UIC sources, it writes out local 8-bit encoding. The
// conversion below is to normalize both the encoding, and the line terminators.
QString normalized = QString::fromLocal8Bit(m_process.readAllStandardOutput());
QByteArray normalized = QString::fromLocal8Bit(m_process.readAllStandardOutput()).toUtf8();
qCDebug(m_log) << "finish process: ok" << normalized.size() << "bytes.";
setCompileTime(QDateTime::currentDateTime());
setContent(targets()[0], normalized);
......
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