summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2010-07-14 22:38:02 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2010-07-14 22:38:02 +0000
commit38e59891ee4417a9be2f8146ce0ba3269e38ac21 (patch)
tree2cbc8f9a8ce3171d4432fc6c7f4bd686aef3b49b /docs
parentd26e89dfcb592e2f51352640822d625ee560aca7 (diff)
downloadllvm-38e59891ee4417a9be2f8146ce0ba3269e38ac21.tar.gz
llvm-38e59891ee4417a9be2f8146ce0ba3269e38ac21.tar.bz2
llvm-38e59891ee4417a9be2f8146ce0ba3269e38ac21.tar.xz
Don't pass StringRef by reference.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108366 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'docs')
-rw-r--r--docs/ProgrammersManual.html17
1 files changed, 8 insertions, 9 deletions
diff --git a/docs/ProgrammersManual.html b/docs/ProgrammersManual.html
index 46fd33f40d..2d3c56555f 100644
--- a/docs/ProgrammersManual.html
+++ b/docs/ProgrammersManual.html
@@ -457,8 +457,8 @@ StringMap class which is used extensively in LLVM and Clang.</p>
may have embedded null characters. Therefore, they cannot simply take
a <tt>const char *</tt>, and taking a <tt>const std::string&amp;</tt> requires
clients to perform a heap allocation which is usually unnecessary. Instead,
-many LLVM APIs use a <tt>const StringRef&amp;</tt> or a <tt>const
-Twine&amp;</tt> for passing strings efficiently.</p>
+many LLVM APIs use a <tt>StringRef</tt> or a <tt>const Twine&amp;</tt> for
+passing strings efficiently.</p>
</div>
@@ -477,19 +477,17 @@ on <tt>std:string</tt>, but does not require heap allocation.</p>
an <tt>std::string</tt>, or explicitly with a character pointer and length.
For example, the <tt>StringRef</tt> find function is declared as:</p>
-<div class="doc_code">
- iterator find(const StringRef &amp;Key);
-</div>
+<pre class="doc_code">
+ iterator find(StringRef Key);
+</pre>
<p>and clients can call it using any one of:</p>
-<div class="doc_code">
-<pre>
+<pre class="doc_code">
Map.find("foo"); <i>// Lookup "foo"</i>
Map.find(std::string("bar")); <i>// Lookup "bar"</i>
Map.find(StringRef("\0baz", 4)); <i>// Lookup "\0baz"</i>
</pre>
-</div>
<p>Similarly, APIs which need to return a string may return a <tt>StringRef</tt>
instance, which can be used directly or converted to an <tt>std::string</tt>
@@ -499,7 +497,8 @@ for more information.</p>
<p>You should rarely use the <tt>StringRef</tt> class directly, because it contains
pointers to external memory it is not generally safe to store an instance of the
-class (unless you know that the external storage will not be freed).</p>
+class (unless you know that the external storage will not be freed). StringRef is
+small and pervasive enough in LLVM that it should always be passed by value.</p>
</div>