| 163 | } |
| 164 | |
| 165 | size_type StringPiece::find_first_of(const StringPiece& s, |
| 166 | size_type pos) const { |
| 167 | if (m_length == 0 || s.m_length == 0) |
| 168 | return npos; |
| 169 | |
| 170 | // Avoid the cost of BuildLookupTable() for a single-character search. |
| 171 | if (s.m_length == 1) |
| 172 | return find_first_of(s.m_ptr[0], pos); |
| 173 | |
| 174 | bool lookup[UCHAR_MAX + 1] = { false }; |
| 175 | BuildLookupTable(s, lookup); |
| 176 | for (size_type i = pos; i < m_length; ++i) { |
| 177 | if (lookup[static_cast<unsigned char>(m_ptr[i])]) { |
| 178 | return i; |
| 179 | } |
| 180 | } |
| 181 | return npos; |
| 182 | } |
| 183 | |
| 184 | size_type StringPiece::find_first_not_of(const StringPiece& s, |
| 185 | size_type pos) const { |