Commit a2ebf9dd authored by Stefan Brüns's avatar Stefan Brüns

Skip base64 encoding of QDataStream, avoid temporary QByteArray

Summary:
There is no need to do any Base64 encoding of the data. Also avoid
streaming the data to an intermediate QByteArray, but directly stream
to stdout.

Test Plan: PATH=`pwd`/bin/:$PATH  ctest

Reviewers: #frameworks, #baloo, astippich, ngraham

Reviewed By: #baloo, ngraham

Tags: #baloo

Differential Revision: https://phabricator.kde.org/D19202
parent 0c782040
......@@ -45,7 +45,7 @@ void ExtractorTest::test()
QCOMPARE(process.exitStatus(), QProcess::NormalExit);
qDebug() << process.readAllStandardError();
QByteArray bytearray = QByteArray::fromBase64(process.readAllStandardOutput());
QByteArray bytearray = process.readAllStandardOutput();
QVariantMap data;
QDataStream in(&bytearray, QIODevice::ReadOnly);
in >> data;
......
......@@ -25,6 +25,7 @@
#include <QMimeDatabase>
#include <QDataStream>
#include <QDebug>
#include <QFile>
#include <KFileMetaData/SimpleExtractionResult>
#include <KFileMetaData/ExtractorCollection>
......@@ -58,8 +59,9 @@ int main(int argc, char **argv)
ex->extract(&result);
}
QByteArray arr;
QDataStream stream(&arr, QIODevice::WriteOnly);
QFile out;
out.open(stdout, QIODevice::WriteOnly);
QDataStream stream(&out);
QVariantMap map;
QMapIterator<KFileMetaData::Property::Property, QVariant> it(result.properties());
......@@ -87,7 +89,6 @@ int main(int argc, char **argv)
stream << map;
qDebug() << map;
std::cout << arr.toBase64().constData();
return 0;
}
......@@ -50,7 +50,7 @@ void IndexedDataRetriever::start()
void IndexedDataRetriever::slotIndexedFile(int)
{
QByteArray data = QByteArray::fromBase64(m_process->readAllStandardOutput());
QByteArray data = m_process->readAllStandardOutput();
QDataStream in(&data, QIODevice::ReadOnly);
in >> m_data;
......
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