summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-09-20 00:38:28 +0000
committerChris Lattner <sabre@nondot.org>2009-09-20 00:38:28 +0000
commit2b807cb364ee751179c20a10b0919cc5343bc01b (patch)
treeeced2b910cce68fc8ac09a112dcee6e3a82dfe92
parenta894053a9b51524408dfcde830d129b719f02cbf (diff)
downloadbcm5719-llvm-2b807cb364ee751179c20a10b0919cc5343bc01b.tar.gz
bcm5719-llvm-2b807cb364ee751179c20a10b0919cc5343bc01b.zip
add size_t and a version of rfind that allows specification of where
to scan from. llvm-svn: 82343
-rw-r--r--llvm/include/llvm/ADT/StringRef.h12
1 files changed, 9 insertions, 3 deletions
diff --git a/llvm/include/llvm/ADT/StringRef.h b/llvm/include/llvm/ADT/StringRef.h
index 01f5d7bef0f..f72a22d70cb 100644
--- a/llvm/include/llvm/ADT/StringRef.h
+++ b/llvm/include/llvm/ADT/StringRef.h
@@ -28,7 +28,8 @@ namespace llvm {
public:
typedef const char *iterator;
static const size_t npos = ~size_t(0);
-
+ typedef size_t size_type;
+
private:
/// The start of the string, in an external buffer.
const char *Data;
@@ -176,14 +177,19 @@ namespace llvm {
///
/// \return - The index of the last occurence of \arg C, or npos if not
/// found.
- size_t rfind(char C) const {
- for (size_t i = Length, e = 0; i != e;) {
+ size_t rfind(char C, size_t From) const {
+ for (size_t i = From, e = 0; i != e;) {
--i;
if (Data[i] == C)
return i;
}
return npos;
}
+
+ size_t rfind(char C) const {
+ return rfind(C, Length);
+ }
+
/// rfind - Search for the last string \arg Str in the string.
///
OpenPOWER on IntegriCloud