[llvm-commits] [llvm] r78883 - /llvm/trunk/include/llvm/ADT/StringRef.h
Daniel Dunbar
daniel at zuster.org
Wed Aug 12 19:03:30 PDT 2009
Author: ddunbar
Date: Wed Aug 12 21:03:30 2009
New Revision: 78883
URL: http://llvm.org/viewvc/llvm-project?rev=78883&view=rev
Log:
Add StringRef::front (with some small tweaks while I was in the area).
- Patch by Erick Tryzelaar
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=78883&r1=78882&r2=78883&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/StringRef.h (original)
+++ llvm/trunk/include/llvm/ADT/StringRef.h Wed Aug 12 21:03:30 2009
@@ -76,14 +76,21 @@
/// size - Get the string size.
size_t size() const { return Length; }
+
+ /// front - Get the first character in the string.
+ char front() const {
+ assert(!empty());
+ return Data[0];
+ }
+ /// back - Get the last character in the string.
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.
+ /// compare() when the relative ordering of inequal strings isn't needed.
bool equals(const StringRef &RHS) const {
return (Length == RHS.Length &&
memcmp(Data, RHS.Data, RHS.Length) == 0);
More information about the llvm-commits
mailing list