MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / addReplyDouble

Function addReplyDouble

src/networking.cpp:830–853  ·  view source on GitHub ↗

Add a double as a bulk reply */

Source from the content-addressed store, hash-verified

828
829/* Add a double as a bulk reply */
830void addReplyDouble(client *c, double d) {
831 if (std::isinf(d)) {
832 /* Libc in odd systems (Hi Solaris!) will format infinite in a
833 * different way, so better to handle it in an explicit way. */
834 if (c->resp == 2) {
835 addReplyBulkCString(c, d > 0 ? "inf" : "-inf");
836 } else {
837 addReplyProto(c, d > 0 ? ",inf\r\n" : ",-inf\r\n",
838 d > 0 ? 6 : 7);
839 }
840 } else {
841 char dbuf[MAX_LONG_DOUBLE_CHARS+3],
842 sbuf[MAX_LONG_DOUBLE_CHARS+32];
843 int dlen, slen;
844 if (c->resp == 2) {
845 dlen = snprintf(dbuf,sizeof(dbuf),"%.17g",d);
846 slen = snprintf(sbuf,sizeof(sbuf),"$%d\r\n%s\r\n",dlen,dbuf);
847 addReplyProto(c,sbuf,slen);
848 } else {
849 dlen = snprintf(dbuf,sizeof(dbuf),",%.17g\r\n",d);
850 addReplyProto(c,dbuf,dlen);
851 }
852 }
853}
854
855void addReplyBigNum(client *c, const char* num, size_t len) {
856 if (c->resp == 2) {

Callers 14

memoryCommandFunction · 0.85
zaddGenericCommandFunction · 0.85
zscoreCommandFunction · 0.85
zmscoreCommandFunction · 0.85
genericZpopCommandFunction · 0.85
debugCommandFunction · 0.85
RM_ReplyWithDoubleFunction · 0.85

Calls 2

addReplyBulkCStringFunction · 0.85
addReplyProtoFunction · 0.85

Tested by

no test coverage detected