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

Method Borrowed

common/internal/byte_string.cc:147–163  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

145}
146
147ByteString ByteString::Borrowed(Borrower borrower, absl::string_view string) {
148 ABSL_DCHECK(borrower != Borrower::None()) << "Borrowing from Owner::None()";
149 auto* arena = borrower.arena();
150 if (string.size() <= kSmallByteStringCapacity || arena != nullptr) {
151 return ByteString(arena, string);
152 }
153 const auto* refcount = BorrowerRelease(borrower);
154 // A nullptr refcount indicates somebody called us to borrow something that
155 // has no owner. If this is the case, we fallback to assuming operator
156 // new/delete and convert it to a reference count.
157 if (refcount == nullptr) {
158 std::tie(refcount, string) = MakeReferenceCountedString(string);
159 } else {
160 StrongRef(*refcount);
161 }
162 return ByteString(refcount, string);
163}
164
165ByteString ByteString::Borrowed(Borrower borrower, const absl::Cord& cord) {
166 ABSL_DCHECK(borrower != Borrower::None()) << "Borrowing from Owner::None()";

Callers

nothing calls this directly

Calls 5

ByteStringFunction · 0.85
StrongRefFunction · 0.85
arenaMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected