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

Method Substring

common/internal/byte_string.cc:377–400  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

375}
376
377ByteString ByteString::Substring(size_t pos, size_t npos) const {
378 ABSL_DCHECK_LE(npos, size());
379 ABSL_DCHECK_LE(pos, npos);
380
381 switch (GetKind()) {
382 case ByteStringKind::kSmall: {
383 ByteString result;
384 result.rep_.header.kind = ByteStringKind::kSmall;
385 result.rep_.small.size = npos - pos;
386 std::memcpy(result.rep_.small.data, rep_.small.data + pos,
387 result.rep_.small.size);
388 result.rep_.small.arena = GetSmallArena();
389 return result;
390 }
391 case ByteStringKind::kMedium: {
392 ByteString result(*this);
393 result.rep_.medium.data += pos;
394 result.rep_.medium.size = npos - pos;
395 return result;
396 }
397 case ByteStringKind::kLarge:
398 return ByteString(GetLarge().Subcord(pos, npos - pos));
399 }
400}
401
402void ByteString::RemovePrefix(size_t n) {
403 ABSL_DCHECK_LE(n, size());

Callers 1

TEST_PFunction · 0.45

Calls 3

GetKindFunction · 0.85
ByteStringFunction · 0.85
sizeFunction · 0.50

Tested by 1

TEST_PFunction · 0.36