Warning, /sdk/clazy/docs/checks/README-container-inside-loop.md is written in an unsupported language. File is not indexed.

0001 # container-inside-loop
0002 
0003 Finds places defining containers inside loops.
0004 Defining them outside the loop and using `resize(0)` will save memory allocations.
0005 
0006 #### Example
0007 
0008     // This will allocate memory at least N times:
0009     for (int i = 0; i < N; ++i) {
0010         QVector<int> v;
0011         (...)
0012         v.append(bar);
0013         (...)
0014     }
0015 
0016     // This will reuse previously allocated memory:
0017     QVector<int> v;
0018     for (int i = 0; i < N; ++i) {
0019         v.resize(0); // resize(0) preserves capacity, unlike QVector::clear()
0020         (...)
0021         v.append(bar);
0022         (...)
0023     }
0024 
0025 #### Supported containers
0026 
0027 `QList`, `QVector` and `std::vector`