Much faster than snprintf(..., "%lu", d);
| 35 | |
| 36 | // Much faster than snprintf(..., "%lu", d); |
| 37 | inline size_t AppendDecimal(char* outbuf, unsigned long d) { |
| 38 | char buf[24]; // enough for decimal 64-bit integers |
| 39 | size_t n = sizeof(buf); |
| 40 | do { |
| 41 | const unsigned long q = d / 10; |
| 42 | buf[--n] = d - q * 10 + '0'; |
| 43 | d = q; |
| 44 | } while (d); |
| 45 | fast_memcpy(outbuf, buf + n, sizeof(buf) - n); |
| 46 | return sizeof(buf) - n; |
| 47 | } |
| 48 | |
| 49 | // This function is the hotspot of RedisCommandFormatV() when format is |
| 50 | // short or does not have many %. In a 100K-time call to formating of |
no test coverage detected