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

Function zzlCompareElements

src/t_zset.cpp:765–783  ·  view source on GitHub ↗

Compare element in sorted set with given element. */

Source from the content-addressed store, hash-verified

763
764/* Compare element in sorted set with given element. */
765int zzlCompareElements(unsigned char *eptr, unsigned char *cstr, unsigned int clen) {
766 unsigned char *vstr;
767 unsigned int vlen;
768 long long vlong;
769 unsigned char vbuf[32];
770 int minlen, cmp;
771
772 serverAssert(ziplistGet(eptr,&vstr,&vlen,&vlong));
773 if (vstr == NULL) {
774 /* Store string representation of long long in buf. */
775 vlen = ll2string((char*)vbuf,sizeof(vbuf),vlong);
776 vstr = vbuf;
777 }
778
779 minlen = (vlen < clen) ? vlen : clen;
780 cmp = memcmp(vstr,cstr,minlen);
781 if (cmp == 0) return vlen-clen;
782 return cmp;
783}
784
785unsigned int zzlLength(const unsigned char *zl) {
786 return ziplistLen(zl)/2;

Callers 1

zzlInsertFunction · 0.85

Calls 2

ziplistGetFunction · 0.85
ll2stringFunction · 0.85

Tested by

no test coverage detected