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

Function EncodeInteger

src/brpc/details/hpack.cpp:479–496  ·  view source on GitHub ↗

Encode variant intger and return the size

Source from the content-addressed store, hash-verified

477
478// Encode variant intger and return the size
479inline void EncodeInteger(butil::IOBufAppender* out, uint8_t msb,
480 uint8_t prefix_size, uint32_t value) {
481 uint8_t max_prefix_value = (1 << prefix_size) - 1;
482 if (value < max_prefix_value) {
483 msb |= value;
484 out->push_back(msb);
485 return;
486 }
487 value -= max_prefix_value;
488 msb |= max_prefix_value;
489 out->push_back(msb);
490 for (; value >= 128; ) {
491 const uint8_t c = (value & 0x7f) | 0x80;
492 value >>= 7;
493 out->push_back(c);
494 }
495 out->push_back(static_cast<uint8_t>(value));
496}
497
498// Static variables
499static HuffmanTree* s_huffman_tree = NULL;

Callers 2

EncodeStringFunction · 0.85
EncodeMethod · 0.85

Calls 1

push_backMethod · 0.45

Tested by

no test coverage detected