aboutsummaryrefslogtreecommitdiffstats
path: root/src/checks/level0/README-qstring-insensitive-allocation.md
blob: d3b2a7e30a0a1ad9c83a3bb3e3b09633fdfb6ab4 (plain)
1
2
3
4
5
6
7
8
9
10
11
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>