diff options
author | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2021-07-27 16:03:23 +0200 |
---|---|---|
committer | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2021-08-04 14:03:21 +0200 |
commit | 07057188e3e42246cf006b43963d0bdcdaa159f5 (patch) | |
tree | 19409bcfde608fd32d5735361f2e1ef865771a6e /src/gui/itemmodels/qfilesystemmodel_p.h | |
parent | fa7f4c5efd91c852341dd2e56396ee3f5fedd33a (diff) |
QFileSystemModel: cache the name filters regexps
In order to filter out file names based on the user's settings,
QFileSystemModel used to have a loop that tested if a given file
name matched one of the filters. The problem is that each filter
(a wildcard) was converted to a QRegularExpression _inside_ the loop.
This causes a quadratic behavior (number of files * number of filters).
Instead, build the regexps once when the filters are set (or the case
sensitivity is changed, as that affects the filtering), and simply
_use_ them in the loop.
Simplify and correct some related code as a drive by.
Done-with: Jean-Michaƫl Celerier
Fixes: QTBUG-95383
Pick-to: 6.2 6.1 5.15
Change-Id: I6bc336364c145bb05793a8f867545d7715d35832
Reviewed-by: Samuel Gaist <samuel.gaist@idiap.ch>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'src/gui/itemmodels/qfilesystemmodel_p.h')
-rw-r--r-- | src/gui/itemmodels/qfilesystemmodel_p.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/gui/itemmodels/qfilesystemmodel_p.h b/src/gui/itemmodels/qfilesystemmodel_p.h index 4acd6a92df..70468460e8 100644 --- a/src/gui/itemmodels/qfilesystemmodel_p.h +++ b/src/gui/itemmodels/qfilesystemmodel_p.h @@ -64,6 +64,8 @@ #include <qtimer.h> #include <qhash.h> +#include <vector> + QT_REQUIRE_CONFIG(filesystemmodel); QT_BEGIN_NAMESPACE @@ -291,6 +293,8 @@ public: QHash<const QFileSystemNode*, bool> bypassFilters; #if QT_CONFIG(regularexpression) QStringList nameFilters; + std::vector<QRegularExpression> nameFiltersRegexps; + void rebuildNameFilterRegexps(); #endif QHash<QString, QString> resolvedSymLinks; |