From 38e59891ee4417a9be2f8146ce0ba3269e38ac21 Mon Sep 17 00:00:00 2001
From: Benjamin Kramer
Date: Wed, 14 Jul 2010 22:38:02 +0000
Subject: Don't pass StringRef by reference.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108366 91177308-0d34-0410-b5e6-96231b3b80d8
---
docs/ProgrammersManual.html | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
(limited to 'docs')
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.
may have embedded null characters. Therefore, they cannot simply take
a const char *, and taking a const std::string& requires
clients to perform a heap allocation which is usually unnecessary. Instead,
-many LLVM APIs use a const StringRef& or a const
-Twine& for passing strings efficiently.
+many LLVM APIs use a StringRef or a const Twine& for
+passing strings efficiently.
@@ -477,19 +477,17 @@ on std:string, but does not require heap allocation.
an std::string, or explicitly with a character pointer and length.
For example, the StringRef find function is declared as:
-
- iterator find(const StringRef &Key);
-
+
+ iterator find(StringRef Key);
+
and clients can call it using any one of:
-
-
+
Map.find("foo"); // Lookup "foo"
Map.find(std::string("bar")); // Lookup "bar"
Map.find(StringRef("\0baz", 4)); // Lookup "\0baz"
-
Similarly, APIs which need to return a string may return a StringRef
instance, which can be used directly or converted to an std::string
@@ -499,7 +497,8 @@ for more information.
You should rarely use the StringRef 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).
+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.
--
cgit v1.2.3-18-g5258