[llvm-commits] [llvm] r82343 - /llvm/trunk/include/llvm/ADT/StringRef.h

Chris Lattner sabre at nondot.org
Sat Sep 19 17:38:28 PDT 2009


Author: lattner
Date: Sat Sep 19 19:38:28 2009
New Revision: 82343

URL: http://llvm.org/viewvc/llvm-project?rev=82343&view=rev
Log:
add size_t and a version of rfind that allows specification of where
to scan from.

Modified:
    llvm/trunk/include/llvm/ADT/StringRef.h

Modified: llvm/trunk/include/llvm/ADT/StringRef.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/StringRef.h?rev=82343&r1=82342&r2=82343&view=diff

==============================================================================
--- llvm/trunk/include/llvm/ADT/StringRef.h (original)
+++ llvm/trunk/include/llvm/ADT/StringRef.h Sat Sep 19 19:38:28 2009
@@ -28,7 +28,8 @@
   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 @@
     ///
     /// \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.
     ///





More information about the llvm-commits mailing list