| 125 | } |
| 126 | |
| 127 | int StringPiece::find_first_of(StringPiece s, size_type pos) const { |
| 128 | if (length_ <= 0 || s.length_ <= 0) { |
| 129 | return npos; |
| 130 | } |
| 131 | // Avoid the cost of BuildLookupTable() for a single-character search. |
| 132 | if (s.length_ == 1) return find_first_of(s.ptr_[0], pos); |
| 133 | |
| 134 | bool lookup[UCHAR_MAX + 1] = { false }; |
| 135 | BuildLookupTable(s, lookup); |
| 136 | for (int i = pos; i < length_; ++i) { |
| 137 | if (lookup[static_cast<unsigned char>(ptr_[i])]) { |
| 138 | return i; |
| 139 | } |
| 140 | } |
| 141 | return npos; |
| 142 | } |
| 143 | |
| 144 | int StringPiece::find_first_not_of(StringPiece s, size_type pos) const { |
| 145 | if (length_ <= 0) return npos; |
no test coverage detected