I'm using QDirIterator to find all subdirectories based on a name filter like this:
nameFilters << "*CAL*";
QDirIterator dirIterator
(path, nameFilters,
QDir::Dirs, QDirIterator
::Subdirectories);
while (dirIterator.hasNext())
{
results << qstr;
}
QStringList nameFilters;
nameFilters << "*CAL*";
QDirIterator dirIterator(path, nameFilters, QDir::Dirs, QDirIterator::Subdirectories);
QStringList results;
while (dirIterator.hasNext())
{
QString qstr = dirIterator.next();
results << qstr;
}
To copy to clipboard, switch view to plain text mode
The path value is a directory that in this case contains over 30,000 files and 1,100 subdirectories. The code returns the correct result, but it is slow (5 seconds or more). It is interesting that the QDirIterator constructor above returns almost immediately, but the next() call within the loop is what takes so long. Is there any reason why this operation would take this long? There are less than 10 directories out of 1,100 that match the name filter, but it takes a long time just to iterate through them.
Bookmarks