Changeset 794


Ignore:
Timestamp:
Oct 14, 2010, 6:12:21 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

Significantly improve the performance of directory iterators walking through directories with thousands of files on slow file systems with inefficient cache policies (closes #176) [based on patch by rudi].

Location:
trunk/src/corelib/io
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/corelib/io/qfsfileengine_iterator.cpp

    r651 r794  
    7272}
    7373
     74
    7475QFileInfo QFSFileEngineIterator::currentFileInfo() const
    7576{
    7677    return QAbstractFileEngineIterator::currentFileInfo();
    7778}
     79
    7880
    7981QT_END_NAMESPACE
  • trunk/src/corelib/io/qfsfileengine_iterator_os2.cpp

    r716 r794  
    4242****************************************************************************/
    4343
     44
     45
     46
    4447#include "qplatformdefs.h"
    4548#include "qfsfileengine_iterator_p.h"
     
    4952#include <QtCore/qvariant.h>
    5053
     54
    5155#include <dirent.h>
    5256#include <unistd.h>
     57
     58
     59
     60
     61
    5362
    5463#ifndef QT_NO_FSFILEENGINE
    5564
    5665QT_BEGIN_NAMESPACE
     66
     67
    5768
    5869class QFSFileEngineIteratorPlatformSpecificData
     
    7687};
    7788
     89
     90
     91
     92
     93
     94
     95
     96
     97
     98
     99
     100
     101
     102
     103
     104
     105
     106
     107
     108
     109
     110
    78111void QFSFileEngineIterator::advance()
    79112{
     113
     114
    80115    currentEntry = platform->dirEntry ? QFile::decodeName(QByteArray(platform->dirEntry->d_name)) : QString();
    81116
     
    99134#endif
    100135    }
     136
     137
     138
     139
     140
     141
     142
     143
     144
     145
     146
     147
     148
     149
     150
     151
     152
     153
     154
     155
     156
     157
    101158}
    102159
     
    108165void QFSFileEngineIterator::deletePlatformSpecifics()
    109166{
     167
     168
    110169    if (platform->dir) {
    111170        ::closedir(platform->dir);
     
    115174#endif
    116175    }
     176
     177
     178
     179
     180
     181
     182
     183
    117184    delete platform;
    118185    platform = 0;
     
    121188bool QFSFileEngineIterator::hasNext() const
    122189{
     190
    123191    if (!platform->done && !platform->dir) {
     192
     193
     194
    124195        QFSFileEngineIterator *that = const_cast<QFSFileEngineIterator *>(this);
    125196        QString path = that->path();
     
    149220            }
    150221        }
     222
    151223        if (arc == ERROR_NOT_READY || arc == ERROR_DISK_CHANGE ||
    152224            arc == ERROR_SECTOR_NOT_FOUND || arc == ERROR_INVALID_DRIVE) {
    153             that->platform->dir = 0;
    154225            that->platform->done = true;
     226
    155227        } else if ((that->platform->dir = ::opendir(QFile::encodeName(path).data())) == 0) {
    156228            that->platform->done = true;
     
    163235            that->platform->mt_file = (dirent *)new char[maxPathName];
    164236#endif
    165 
    166237            that->advance();
     238
     239
     240
     241
     242
     243
     244
     245
     246
     247
     248
     249
     250
     251
     252
    167253        }
    168254    }
     255
    169256    return !platform->done;
    170257}
    171258
     259
     260
     261
     262
     263
     264
     265
     266
     267
     268
     269
     270
     271
     272
     273
     274
     275
     276
     277
     278
     279
     280
     281
     282
     283
     284
     285
     286
     287
     288
     289
     290
     291
     292
     293
     294
     295
     296
     297
     298
     299
     300
     301
     302
     303
     304
     305
     306
     307
     308
     309
     310
     311
     312
     313
     314
     315
     316
     317
     318
     319
     320
     321
     322
     323
     324
     325
     326
     327
     328
     329
     330
     331
     332
     333
     334
     335
     336
     337
    172338QT_END_NAMESPACE
    173339
  • trunk/src/corelib/io/qfsfileengine_os2.cpp

    r793 r794  
    4242****************************************************************************/
    4343
     44
     45
     46
    4447#include "qplatformdefs.h"
    4548#include "qabstractfileengine.h"
     
    661664            is_link = false;        // drive/share names are never symlinks
    662665        } else {
     666
     667
     668
    663669            QT_STATBUF st;          // don't clobber our main one
    664670            that->is_link = (QT_LSTAT(nativeFilePath.constData(), &st) == 0) ?
    665671                            S_ISLNK(st.st_mode) : false;
     672
    666673        }
    667674    }
Note: See TracChangeset for help on using the changeset viewer.