diff options
author | Chris Lattner <sabre@nondot.org> | 2009-09-20 22:54:26 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-09-20 22:54:26 +0000 |
commit | a094468e10fe4f091e7d907293becbdcfbd6427e (patch) | |
tree | 16b01f3f40000e2e99d42a160ddbf175167c8eb4 /include | |
parent | 637012fa510c7edf6b964a351eb3f265ed799674 (diff) | |
download | external_llvm-a094468e10fe4f091e7d907293becbdcfbd6427e.zip external_llvm-a094468e10fe4f091e7d907293becbdcfbd6427e.tar.gz external_llvm-a094468e10fe4f091e7d907293becbdcfbd6427e.tar.bz2 |
write rfind in terms of npos as daniel requested
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82414 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/ADT/StringRef.h | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/include/llvm/ADT/StringRef.h b/include/llvm/ADT/StringRef.h index 510a51b..e4fd258 100644 --- a/include/llvm/ADT/StringRef.h +++ b/include/llvm/ADT/StringRef.h @@ -169,8 +169,10 @@ namespace llvm { /// /// \return - The index of the last occurence of \arg C, or npos if not /// found. - size_t rfind(char C, size_t From) const { - for (size_t i = From, e = 0; i != e;) { + size_t rfind(char C, size_t From = npos) const { + From = std::min(From, Length); + size_t i = From; + while (i != 0) { --i; if (Data[i] == C) return i; @@ -178,10 +180,6 @@ namespace llvm { return npos; } - size_t rfind(char C) const { - return rfind(C, Length); - } - /// rfind - Search for the last string \arg Str in the string. /// /// \return - The index of the last occurence of \arg Str, or npos if not |