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
This commit is contained in:
Chris Lattner 2009-09-20 22:54:26 +00:00
parent 19e74991f3
commit c936fe8cb3

View File

@ -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