Add a long long as integer reply or bulk len / multi bulk count. * Basically this is used to output . */
| 723 | /* Add a long long as integer reply or bulk len / multi bulk count. |
| 724 | * Basically this is used to output <prefix><long long><crlf>. */ |
| 725 | void addReplyLongLongWithPrefix(client *c, long long ll, char prefix) { |
| 726 | char buf[128]; |
| 727 | int len; |
| 728 | |
| 729 | /* Things like $3\r\n or *2\r\n are emitted very often by the protocol |
| 730 | * so we have a few shared objects to use if the integer is small |
| 731 | * like it is most of the times. */ |
| 732 | if (prefix == '*' && ll < OBJ_SHARED_BULKHDR_LEN && ll >= 0) { |
| 733 | addReply(c,shared.mbulkhdr[ll]); |
| 734 | return; |
| 735 | } else if (prefix == '$' && ll < OBJ_SHARED_BULKHDR_LEN && ll >= 0) { |
| 736 | addReply(c,shared.bulkhdr[ll]); |
| 737 | return; |
| 738 | } |
| 739 | |
| 740 | buf[0] = prefix; |
| 741 | len = ll2string(buf+1,sizeof(buf)-1,ll); |
| 742 | buf[len+1] = '\r'; |
| 743 | buf[len+2] = '\n'; |
| 744 | addReplyProto(c,buf,len+3); |
| 745 | } |
| 746 | |
| 747 | void addReplyLongLong(client *c, long long ll) { |
| 748 | if (ll == 0) |
no test coverage detected