MCPcopy Create free account
hub / github.com/apache/brpc / fetch

Method fetch

src/butil/iobuf.cpp:1352–1374  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1350}
1351
1352void const* IOBuf::fetch(void* d, size_t n) const {
1353 if (n <= length()) {
1354 IOBuf::BlockRef const& r0 = _ref_at(0);
1355 if (n <= r0.length) {
1356 return r0.block->data + r0.offset;
1357 }
1358
1359 iobuf::cp(d, r0.block->data + r0.offset, r0.length);
1360 size_t total_nc = r0.length;
1361 const size_t nref = _ref_num();
1362 for (size_t i = 1; i < nref; ++i) {
1363 IOBuf::BlockRef const& r = _ref_at(i);
1364 if (n <= r.length + total_nc) {
1365 iobuf::cp((char*)d + total_nc,
1366 r.block->data + r.offset, n - total_nc);
1367 return d;
1368 }
1369 iobuf::cp((char*)d + total_nc, r.block->data + r.offset, r.length);
1370 total_nc += r.length;
1371 }
1372 }
1373 return NULL;
1374}
1375
1376const void* IOBuf::fetch1() const {
1377 if (!empty()) {

Callers 15

TEST_FFunction · 0.80
TEST_FFunction · 0.80
ReadHeaderMethod · 0.80
ReadMethod · 0.80
CreateMethod · 0.80
PopMethod · 0.80
ProcessNsheadRequestFunction · 0.80
ParseMemcacheMessageFunction · 0.80
ParseMongoMessageFunction · 0.80
ProcessMongoRequestFunction · 0.80

Calls 2

cpFunction · 0.85
lengthFunction · 0.50

Tested by 2

TEST_FFunction · 0.64
TEST_FFunction · 0.64