summaryrefslogtreecommitdiffstats
path: root/llvm/docs/ProgrammersManual.html
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-02-05 06:30:51 +0000
committerChris Lattner <sabre@nondot.org>2007-02-05 06:30:51 +0000
commit9132f16d6c0ab88165974436a54796b46dd30ee5 (patch)
tree401a0517dba3bcc554431324781dfbb337b224dc /llvm/docs/ProgrammersManual.html
parentc04536470a68997781cdd95206fbd95231562699 (diff)
downloadbcm5719-llvm-9132f16d6c0ab88165974436a54796b46dd30ee5.tar.gz
bcm5719-llvm-9132f16d6c0ab88165974436a54796b46dd30ee5.zip
add a note
llvm-svn: 33904
Diffstat (limited to 'llvm/docs/ProgrammersManual.html')
-rw-r--r--llvm/docs/ProgrammersManual.html27
1 files changed, 27 insertions, 0 deletions
diff --git a/llvm/docs/ProgrammersManual.html b/llvm/docs/ProgrammersManual.html
index 1d5ad0e82c0..c4fedbf5d7b 100644
--- a/llvm/docs/ProgrammersManual.html
+++ b/llvm/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 :).
</p>
+
+<p>One worthwhile note about std::vector: avoid code like this:</p>
+
+<div class="doc_code">
+<pre>
+for ( ... ) {
+ std::vector<foo> V;
+ use V;
+}
+</pre>
+</div>
+
+<p>Instead, write this as:</p>
+
+<div class="doc_code">
+<pre>
+std::vector<foo> V;
+for ( ... ) {
+ use V;
+ V.clear();
+}
+</pre>
+</div>
+
+<p>Doing so will save (at least) one heap allocation and free per iteration of
+the loop.</p>
+
</div>
<!-- _______________________________________________________________________ -->
OpenPOWER on IntegriCloud