| 300 | } |
| 301 | |
| 302 | absl::optional<size_t> ByteString::Find(absl::string_view needle, |
| 303 | size_t pos) const { |
| 304 | ABSL_DCHECK_LE(pos, size()); |
| 305 | |
| 306 | return Visit(absl::Overload( |
| 307 | [&needle, pos](absl::string_view lhs) -> absl::optional<size_t> { |
| 308 | absl::string_view::size_type i = lhs.find(needle, pos); |
| 309 | if (i == absl::string_view::npos) { |
| 310 | return absl::nullopt; |
| 311 | } |
| 312 | return i; |
| 313 | }, |
| 314 | [&needle, pos](const absl::Cord& lhs) -> absl::optional<size_t> { |
| 315 | absl::Cord cord = lhs.Subcord(pos, lhs.size() - pos); |
| 316 | absl::Cord::CharIterator it = cord.Find(needle); |
| 317 | if (it == cord.char_end()) { |
| 318 | return absl::nullopt; |
| 319 | } |
| 320 | return pos + |
| 321 | static_cast<size_t>(absl::Cord::Distance(cord.char_begin(), it)); |
| 322 | })); |
| 323 | } |
| 324 | |
| 325 | absl::optional<size_t> ByteString::Find(const absl::Cord& needle, |
| 326 | size_t pos) const { |