add size_t and a version of rfind that allows specification of where
authorChris Lattner <sabre@nondot.org>
Sun, 20 Sep 2009 00:38:28 +0000 (00:38 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 20 Sep 2009 00:38:28 +0000 (00:38 +0000)
to scan from.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82343 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ADT/StringRef.h

index 01f5d7bef0ff5cac39f8eeb4d1c57d5e9927e7dd..f72a22d70cb3e88ce9a193601428ad77dcc20a31 100644 (file)
@@ -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.
     ///