I have the following piece of code:
void Class
::processElements(const QString & aInputFile,
{
QFile queryFile
(QString(":queries/") + "syncronizationresponse.xq");
if (queryFile.
open(QFile::ReadOnly)) {
QString queryString
(queryFile.
readAll());
QFile sourceDocument
(aInputFile
);
if (sourceDocument.
open(QIODevice::ReadOnly)) {
//Create query
QXmlQuery query;
query.bindVariable("inputDocument", &sourceDocument);
query.
bindVariable("bindedVariable",
QVariant(aNodeName
));
query.setQuery(queryString);
if(query.isValid())
{
//Evaluate
{
QXmlSerializer xmlSerializer(query, &buffer);
if (query.evaluateTo(&xmlSerializer))
{
//Process the stuff in the byteArray
}
else
qDebug() << "Evaluation to serializer failed";
}
else
{
qDebug() << "Opening output buffer failed " << buffer.errorString();
}
//Starting to close buffer for "ROUTE" "ke 8. huhti 06:53:37 2009"
buffer.close();
//Finished closing buffer for "ROUTE" "ke 8. huhti 06:53:37 2009"
}
else
{
qDebug() << "XmlQuery failed";
}
}
else
{
qDebug() << "Opening input file failed " << sourceDocument.errorString();
}
//Starting to close source document for "ROUTE" "ke 8. huhti 06:53:46 2009"
sourceDocument.close();
//Finished closing source document for "ROUTE" "ke 8. huhti 06:53:46 2009"
}
else
{
qDebug() << "Opening query file failed " << queryFile.errorString();
}
//Starting to close query file for "ROUTE" "ke 8. huhti 06:53:46 2009"
queryFile.close();
//Finished closing query file for "ROUTE" "ke 8. huhti 06:53:46 2009"
}
void Class::processElements(const QString & aInputFile,
const QString & aNodeName)
{
QFile queryFile(QString(":queries/") + "syncronizationresponse.xq");
if (queryFile.open(QFile::ReadOnly))
{
QString queryString(queryFile.readAll());
QFile sourceDocument(aInputFile);
if (sourceDocument.open(QIODevice::ReadOnly))
{
//Create query
QXmlQuery query;
query.bindVariable("inputDocument", &sourceDocument);
query.bindVariable("bindedVariable", QVariant(aNodeName));
query.setQuery(queryString);
if(query.isValid())
{
//Evaluate
QByteArray byteArray;
QBuffer buffer(&byteArray);
if (buffer.open(QIODevice::ReadWrite))
{
QXmlSerializer xmlSerializer(query, &buffer);
if (query.evaluateTo(&xmlSerializer))
{
//Process the stuff in the byteArray
}
else
qDebug() << "Evaluation to serializer failed";
}
else
{
qDebug() << "Opening output buffer failed " << buffer.errorString();
}
//Starting to close buffer for "ROUTE" "ke 8. huhti 06:53:37 2009"
buffer.close();
//Finished closing buffer for "ROUTE" "ke 8. huhti 06:53:37 2009"
}
else
{
qDebug() << "XmlQuery failed";
}
}
else
{
qDebug() << "Opening input file failed " << sourceDocument.errorString();
}
//Starting to close source document for "ROUTE" "ke 8. huhti 06:53:46 2009"
sourceDocument.close();
//Finished closing source document for "ROUTE" "ke 8. huhti 06:53:46 2009"
}
else
{
qDebug() << "Opening query file failed " << queryFile.errorString();
}
//Starting to close query file for "ROUTE" "ke 8. huhti 06:53:46 2009"
queryFile.close();
//Finished closing query file for "ROUTE" "ke 8. huhti 06:53:46 2009"
}
To copy to clipboard, switch view to plain text mode
Who can tell me why the heck it takes 9 seconds from buffer.close(); to sourceDocument.close(); ?? There should not be anything that slows it down? Unless it has something to do with signals that the QBuffer emits when close is called? Does anyone know what makes close call to QBuffer so slow??
BR, Kimmo
Bookmarks