Skip to content

Latest commit

 

History

History
18 lines (12 loc) · 685 Bytes

README-qdeleteall.md

File metadata and controls

18 lines (12 loc) · 685 Bytes

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 QObjects 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.