Closed spillerrec closed 10 years ago
QDir::entryInfoList() do use QDirIterator in its implementation, what showed to be the real issue was LocaleAware sorting. (Using QDirIterator) it takes 4.5 seconds with LocaleAware and 0.120 seconds with value based sorting (for 12,000 files). QCollator intends to solve this issue, but it is not public yet.
(Using QDirIterator directly still appears to be a better choice, as QDir::entryInfoList() appears to make several copies of the array.)
As a workaround, you can now disable locale aware sorting by setting "locale-sorting" to "false" in the configuration group "loading".
Qt5.2 out with a new class to fix exactly this issue
Using QDir::entryInfoList() is slow, in a directory containing 5000+ files it easily takes several seconds. (Tested on Linux) This is not an issue on startup, but when such a directory have rapid changes, it freezes the UI as it constantly tries to reload. (Do consider delayed directory listing loading though.)
Alternative implementations: QDirIterator boost::filesystem Both do not filter its results! Use QDirIterator if boost is not significant faster.
Filtering might be what is slowing down entryInfoList(). We check on extension and we have quite a bit of them. Secondly it is matched using RegExp which is probably not optimal. We could furthermore sort the extension list to speed up matching.
While a much smaller issue (~100ms), restoring old caches makes use of indexOf(), giving us O(n²) instead of O(n). If we keep the list sorted we can avoid this. It might also be worth investigating better alternatives to QFileSystemWatcher. If we can guaranty that we will be informed of all changes, we can keep the file list up-to-date instead of reloading it completely.