| 169 | } |
| 170 | |
| 171 | int StringPiece::find_last_of(StringPiece s, size_type pos) const { |
| 172 | if (length_ <= 0 || s.length_ <= 0) return npos; |
| 173 | // Avoid the cost of BuildLookupTable() for a single-character search. |
| 174 | if (s.length_ == 1) return find_last_of(s.ptr_[0], pos); |
| 175 | |
| 176 | bool lookup[UCHAR_MAX + 1] = { false }; |
| 177 | BuildLookupTable(s, lookup); |
| 178 | for (int i = min(pos, static_cast<size_type>(length_ - 1)); |
| 179 | i >= 0; --i) { |
| 180 | if (lookup[static_cast<unsigned char>(ptr_[i])]) { |
| 181 | return i; |
| 182 | } |
| 183 | } |
| 184 | return npos; |
| 185 | } |
| 186 | |
| 187 | int StringPiece::find_last_not_of(StringPiece s, size_type pos) const { |
| 188 | if (length_ <= 0) return npos; |
no test coverage detected