MCPcopy Create free account
hub / github.com/F-Stack/f-stack / sdscmp

Function sdscmp

app/redis-6.2.6/src/sds.c:834–844  ·  view source on GitHub ↗

Compare two sds strings s1 and s2 with memcmp(). * * Return value: * * positive if s1 > s2. * negative if s1 < s2. * 0 if s1 and s2 are exactly the same binary string. * * If two strings share exactly the same prefix, but one of the two has * additional characters, the longer string is considered to be greater than * the smaller one. */

Source from the content-addressed store, hash-verified

832 * additional characters, the longer string is considered to be greater than
833 * the smaller one. */
834int sdscmp(const sds s1, const sds s2) {
835 size_t l1, l2, minlen;
836 int cmp;
837
838 l1 = sdslen(s1);
839 l2 = sdslen(s2);
840 minlen = (l1 < l2) ? l1 : l2;
841 cmp = memcmp(s1,s2,minlen);
842 if (cmp == 0) return l1>l2? 1: (l1<l2? -1: 0);
843 return cmp;
844}
845
846/* Split 's' with separator in 'sep'. An array
847 * of sds strings is returned. *count will be set

Callers 15

rewriteConfigSdsOptionFunction · 0.85
clusterManagerNodeByNameFunction · 0.85
zslDefragFunction · 0.85
renameGenericCommandFunction · 0.85
copyCommandFunction · 0.85
ACLListMatchSdsFunction · 0.85
ACLLogMatchEntryFunction · 0.85
zslInsertFunction · 0.85
zslDeleteFunction · 0.85

Calls 1

sdslenFunction · 0.85

Tested by

no test coverage detected