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

Chris Lattner sabre at nondot.org
Sun Aug 9 17:44:03 PDT 2009


Author: lattner
Date: Sun Aug  9 19:44:02 2009
New Revision: 78544

URL: http://llvm.org/viewvc/llvm-project?rev=78544&view=rev
Log:
add a simple back() method to StringRef.

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=78544&r1=78543&r2=78544&view=diff

==============================================================================
--- llvm/trunk/include/llvm/ADT/StringRef.h (original)
+++ llvm/trunk/include/llvm/ADT/StringRef.h Sun Aug  9 19:44:02 2009
@@ -76,6 +76,11 @@
 
     /// size - Get the string size.
     size_t size() const { return Length; }
+    
+    char back() const {
+      assert(!empty());
+      return Data[Length-1];
+    }
 
     /// equals - Check for string equality, this is more efficient than
     /// compare() in when the relative ordering of inequal strings isn't needed.





More information about the llvm-commits mailing list