summaryrefslogtreecommitdiffstats
path: root/src/corelib/doc
diff options
context:
space:
mode:
authorAhmad Samir <a.samirh78@gmail.com>2023-05-05 20:12:27 +0300
committerAhmad Samir <a.samirh78@gmail.com>2023-10-22 14:37:33 +0300
commita6ad755734930fabec6d91c6a516725e80a3084a (patch)
treeb10b70cbc62843ecd6b92999d4508f33202c6dc4 /src/corelib/doc
parentfeb67bbdd202ac708cbf41f5698c4e2246ad4232 (diff)
QStringList: add filter(QStringMatcher) overload
Now that users can pass a QStringMatcher to do the matching, change the existing overload to not use QStringMatcher. Thanks to Giuseppe D'Angelo for the idea of passing a QStringMatcher to filter instead of using a magic number to decide whether to use QStringMatcher or not. Results of running filter() and filter_stringMatcher, times are in msecs and this was compiled with gcc -O3: Without With QStringMatcher list10 0.00022 0.000089 list20 0.00040 0.00014 list30 0.00058 0.00018 list40 0.000770 0.00023 list50 0.00094 0.00027 list70 0.0012 0.00037 list80 0.0014 0.00041 list100 0.0018 0.00050 list300 0.0054 0.0014 list500 0.0091 0.0023 list700 0.012 0.0032 list900 0.016 0.0041 list10000 0.17 0.045 Drive-by change: optimize tst_QStringList::populateList(). [ChangeLog][QtCore][QStringList] Added filter(const QStringMatcher &) overload, which may be faster for large lists and/or lists with very long strings. [ChangeLog][Possible Performance Changes][QtCore][QStringList] Changed the implementation of filter(QStringView) overload to not use QStringMatcher by default. Using QStringMatcher adds overhead, so it is beneficial/faster when searching for a pattern in large lists and/or lists with long strings, otherwise using plain string comparison is faster. If using QStringMatcher makes a difference in your code, you can use the newly added filter(QStringMatcher) overload. Change-Id: I7bb1262706d673f0ce0d9b7699f03c995ce28677 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/doc')
-rw-r--r--src/corelib/doc/snippets/qstringlist/main.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/corelib/doc/snippets/qstringlist/main.cpp b/src/corelib/doc/snippets/qstringlist/main.cpp
index e9567fb107..1b7453cf6a 100644
--- a/src/corelib/doc/snippets/qstringlist/main.cpp
+++ b/src/corelib/doc/snippets/qstringlist/main.cpp
@@ -93,6 +93,13 @@ Widget::Widget(QWidget *parent)
// list == ["Bill Clinton", "Bill Murray"]
//! [17]
+ {
+//! [18]
+ QStringList veryLongList;
+ QStringMatcher matcher(u"Straße", Qt::CaseInsensitive);
+ QStringList filtered = veryLongList.filter(matcher);
+//! [18]
+ }
}
int main(int argc, char *argv[])