aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm/ADT/StringRef.h
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-08-13 02:03:30 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-08-13 02:03:30 +0000
commitac55b85438da378bab227fd34167bb0c4a9249aa (patch)
tree8da6bf50e8c21eb60b7adc328d617016905928ba /include/llvm/ADT/StringRef.h
parentd06791f6d0b302eeee7189ea8182565594ffdc0e (diff)
downloadexternal_llvm-ac55b85438da378bab227fd34167bb0c4a9249aa.zip
external_llvm-ac55b85438da378bab227fd34167bb0c4a9249aa.tar.gz
external_llvm-ac55b85438da378bab227fd34167bb0c4a9249aa.tar.bz2
Add StringRef::front (with some small tweaks while I was in the area).
- Patch by Erick Tryzelaar git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78883 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/ADT/StringRef.h')
-rw-r--r--include/llvm/ADT/StringRef.h9
1 files changed, 8 insertions, 1 deletions
diff --git a/include/llvm/ADT/StringRef.h b/include/llvm/ADT/StringRef.h
index b239e3b..40689a9 100644
--- a/include/llvm/ADT/StringRef.h
+++ b/include/llvm/ADT/StringRef.h
@@ -76,14 +76,21 @@ namespace llvm {
/// 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);