blob: 3baea8525bb6bfc9507df7dd2942cf6ec67770d8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
# qdeleteall
Finds places where a call to `qDeleteAll()` has a redundant `values()` or `keys()` call.
Those calls create a temporary `QList<int>` and allocate memory.
#### Example
QSet<Cookies> set;
// BAD: Unneeded container iteration and memory allocation to construct list of values
qDeleteAll(set.values());
// GOOD: Unneeded container iteration and memory allocation to construct list of values
qDeleteAll(set);
#### Pitfalls
Very rarely you might be deleting a list of `QObject`s who's `destroyed()` signal is connected to some code
that modifies the original container. In the case of this contrived example iterating over the container copy is safer.
|