| 216 | } |
| 217 | |
| 218 | size_type StringPiece::find_last_of(const StringPiece& s, size_type pos) const { |
| 219 | if (m_length == 0 || s.m_length == 0) |
| 220 | return npos; |
| 221 | |
| 222 | // Avoid the cost of BuildLookupTable() for a single-character search. |
| 223 | if (s.m_length == 1) |
| 224 | return find_last_of(s.m_ptr[0], pos); |
| 225 | |
| 226 | bool lookup[UCHAR_MAX + 1] = { false }; |
| 227 | BuildLookupTable(s, lookup); |
| 228 | for (size_type i = std::min(pos, m_length - 1); ; --i) { |
| 229 | if (lookup[static_cast<unsigned char>(m_ptr[i])]) |
| 230 | return i; |
| 231 | if (i == 0) |
| 232 | break; |
| 233 | } |
| 234 | return npos; |
| 235 | } |
| 236 | |
| 237 | size_type StringPiece::find_last_not_of(const StringPiece& s, |
| 238 | size_type pos) const { |