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

Function AppendHeader

src/brpc/redis_command.cpp:53–60  ·  view source on GitHub ↗

This function is the hotspot of RedisCommandFormatV() when format is short or does not have many %. In a 100K-time call to formating of "GET key1", the time spent on RedisRequest.AddCommand() are ~700ns vs. ~400ns while using snprintf() vs. AppendDecimal() respectively.

Source from the content-addressed store, hash-verified

51// "GET key1", the time spent on RedisRequest.AddCommand() are ~700ns
52// vs. ~400ns while using snprintf() vs. AppendDecimal() respectively.
53inline void AppendHeader(std::string& buf, char fc, unsigned long value) {
54 char header[32];
55 header[0] = fc;
56 size_t len = AppendDecimal(header + 1, value);
57 header[len + 1] = '\r';
58 header[len + 2] = '\n';
59 buf.append(header, len + 3);
60}
61inline void AppendHeader(butil::IOBuf& buf, char fc, unsigned long value) {
62 char header[32];
63 header[0] = fc;

Callers 4

FlushComponentFunction · 0.85
RedisCommandFormatVFunction · 0.85
RedisCommandNoFormatFunction · 0.85
RedisCommandByComponentsFunction · 0.85

Calls 2

AppendDecimalFunction · 0.85
appendMethod · 0.45

Tested by

no test coverage detected