llvm.org GIT mirror llvm / ac55b85
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 Daniel Dunbar 10 years ago
1 changed file(s) with 8 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
7575
7676 /// size - Get the string size.
7777 size_t size() const { return Length; }
78
79 /// front - Get the first character in the string.
80 char front() const {
81 assert(!empty());
82 return Data[0];
83 }
7884
85 /// back - Get the last character in the string.
7986 char back() const {
8087 assert(!empty());
8188 return Data[Length-1];
8289 }
8390
8491 /// equals - Check for string equality, this is more efficient than
85 /// compare() in when the relative ordering of inequal strings isn't needed.
92 /// compare() when the relative ordering of inequal strings isn't needed.
8693 bool equals(const StringRef &RHS) const {
8794 return (Length == RHS.Length &&
8895 memcmp(Data, RHS.Data, RHS.Length) == 0);