0
votes

Next two strings of Qt C++ code do the same stuff and without any problems to me.

QFile(source).copy(destination); 
QFile::copy(source, destination);

The question is about performance of first and second. Does code of Qt optimised inside static method and doesn't it create two objects? Which one is better and etc.

1
Why didn't you simply measure runtime? - Silicomancer
Or look into the sources yourself? - demonplus
I prefer the first version because you can get details when it fails, via errorString() - Frank Osterfeld

1 Answers

3
votes

From Qt 5.5.1:

bool  QFile::copy(const QString &fileName, const QString &newName)
{
    return QFile(fileName).copy(newName);
}

Hope that give's you an idea =)