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.
| 51 | // "GET key1", the time spent on RedisRequest.AddCommand() are ~700ns |
| 52 | // vs. ~400ns while using snprintf() vs. AppendDecimal() respectively. |
| 53 | inline 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 | } |
| 61 | inline void AppendHeader(butil::IOBuf& buf, char fc, unsigned long value) { |
| 62 | char header[32]; |
| 63 | header[0] = fc; |
no test coverage detected