MCPcopy Create free account
hub / github.com/cel-expr/cel-cpp / Find

Method Find

common/internal/byte_string.cc:302–323  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

300}
301
302absl::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
325absl::optional<size_t> ByteString::Find(const absl::Cord& needle,
326 size_t pos) const {

Callers

nothing calls this directly

Calls 5

TryFlatMethod · 0.80
VisitFunction · 0.70
sizeFunction · 0.50
sizeMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected