diff --git a/docs/ProgrammersManual.html b/docs/ProgrammersManual.html index 1d5ad0e82c0..c4fedbf5d7b 100644 --- a/docs/ProgrammersManual.html +++ b/docs/ProgrammersManual.html @@ -797,6 +797,33 @@ rarely be a benefit) or if you will be allocating many instances of the vector itself (which would waste space for elements that aren't in the container). vector is also useful when interfacing with code that expects vectors :).
+ +One worthwhile note about std::vector: avoid code like this:
+ ++for ( ... ) { + std::vector+V; + use V; +} +
Instead, write this as:
+ ++std::vector+V; +for ( ... ) { + use V; + V.clear(); +} +
Doing so will save (at least) one heap allocation and free per iteration of +the loop.
+