summaryrefslogtreecommitdiff
path: root/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
commit32d84765c8e9e6bcfd5a012ceb625d64c44a373b (patch)
treee00845cedd593dbfff710435c45b8065b740b2b8 /docs/ProgrammersManual.html
parent90a2eb02e50f171866d03aab56db868c3f3a1cec (diff)
downloadllvm-32d84765c8e9e6bcfd5a012ceb625d64c44a373b.tar.gz
llvm-32d84765c8e9e6bcfd5a012ceb625d64c44a373b.tar.bz2
llvm-32d84765c8e9e6bcfd5a012ceb625d64c44a373b.tar.xz
add a note
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33904 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'docs/ProgrammersManual.html')
-rw-r--r--docs/ProgrammersManual.html27
1 files changed, 27 insertions, 0 deletions
diff --git a/docs/ProgrammersManual.html b/docs/ProgrammersManual.html
index 1d5ad0e82c..c4fedbf5d7 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 :).
</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>
<!-- _______________________________________________________________________ -->