aboutsummaryrefslogtreecommitdiffstats
path: root/docs/checks/README-qstring-insensitive-allocation.md
diff options
context:
space:
mode:
Diffstat (limited to 'docs/checks/README-qstring-insensitive-allocation.md')
-rw-r--r--docs/checks/README-qstring-insensitive-allocation.md12
1 files changed, 12 insertions, 0 deletions
diff --git a/docs/checks/README-qstring-insensitive-allocation.md b/docs/checks/README-qstring-insensitive-allocation.md
new file mode 100644
index 00000000..d3b2a7e3
--- /dev/null
+++ b/docs/checks/README-qstring-insensitive-allocation.md
@@ -0,0 +1,12 @@
+# qstring-insensitive-allocation
+
+Finds unneeded memory allocations such as
+ `if (str.toLower().contains("foo"))` which you should fix as
+ `if (str.contains("foo", Qt::CaseInsensitive))` to avoid the heap allocation caused by toLower().
+
+Matches any of the following cases:
+ `str.{toLower, toUpper}().{contains, compare, startsWith, endsWith}()`
+
+#### Pitfalls
+`Qt::CaseInsensitive` is different from `QString::toLower()` comparison for a few code points, but it
+should be very rare: <http://lists.qt-project.org/pipermail/development/2016-February/024776.html>