Reading from a file realized with Qt/MinGW is slower than in Delphi 7
-
I need to read a simple structured file.
This is an algorithm
@
bool Reader::readTo(void *dest)
{
if (!file->open(QIODevice::ReadOnly) || !dest) return false;
QTextStream in(file);
Data *data = (Data *) dest;QString line = "";
QString datetime;
Point *point;
int size = 0;
data->clear();
while ((!in.atEnd()) || !line.contains("//STOP", Qt::CaseInsensitive)){
line = in.readLine();
size += line.size();
int index = line.indexOf('[');
if (index != -1) {
datetime = line.mid(0, index);
point = new Point();
point->date = QDateTime::fromString(datetime, "<yy/MM/dd>(hh:mm:ss:z)");
point->date = point->date.addYears(100);
QStringList data = line.mid(index + 1, line.count() - index - 2).split(" ");for (int i = 0; i < count; i++)
{
point.data.append(data.at(i).toInt());
}
data->append(*point);
delete point;
}
}
file->close();
return true;
}
@So, that algorithm is 20% slower than analogue in Delphi. I noticed that the most expensive operation is data.at(i).toInt(). Maybe I compiled Qt wrong? Any ideas?
-
Could you please mark up your code as code? Thanks!