Skip to content

Commit

Permalink
Merge branch 'unstable' of https://github.com/EQ-Alpha/KeyDB into uns…
Browse files Browse the repository at this point in the history
…table
  • Loading branch information
msotheeswaran-sc committed Apr 12, 2022
2 parents 9bb439d + af7257c commit a12dcea
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
3 changes: 2 additions & 1 deletion src/pqsort.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@

#include <errno.h>
#include <stdlib.h>
#include <stdint.h>

static inline char *med3 (char *, char *, char *,
int (*)(const void *, const void *));
Expand All @@ -62,7 +63,7 @@ static inline void swapfunc (char *, char *, size_t, int);
} while (--i > 0); \
}

#define SWAPINIT(a, es) swaptype = ((char *)a - (char *)0) % sizeof(long) || \
#define SWAPINIT(a, es) swaptype = (uintptr_t)a % sizeof(long) || \
es % sizeof(long) ? 2 : es == sizeof(long)? 0 : 1;

static inline void
Expand Down
34 changes: 18 additions & 16 deletions src/t_zset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1191,24 +1191,26 @@ void zsetConvert(robj *zobj, int encoding) {
zs->dict = dictCreate(&zsetDictType,NULL);
zs->zsl = zslCreate();

eptr = ziplistIndex(zl,0);
serverAssertWithInfo(NULL,zobj,eptr != NULL);
sptr = ziplistNext(zl,eptr);
serverAssertWithInfo(NULL,zobj,sptr != NULL);

while (eptr != NULL) {
score = zzlGetScore(sptr);
serverAssertWithInfo(NULL,zobj,ziplistGet(eptr,&vstr,&vlen,&vlong));
if (vstr == NULL)
ele = sdsfromlonglong(vlong);
else
ele = sdsnewlen((char*)vstr,vlen);
if (ziplistLen(zl) > 0) {
eptr = ziplistIndex(zl,0);
serverAssertWithInfo(NULL,zobj,eptr != NULL);
sptr = ziplistNext(zl,eptr);
serverAssertWithInfo(NULL,zobj,sptr != NULL);

node = zslInsert(zs->zsl,score,ele);
serverAssert(dictAdd(zs->dict,ele,&node->score) == DICT_OK);
zzlNext(zl,&eptr,&sptr);
while (eptr != NULL) {
score = zzlGetScore(sptr);
serverAssertWithInfo(NULL,zobj,ziplistGet(eptr,&vstr,&vlen,&vlong));
if (vstr == NULL)
ele = sdsfromlonglong(vlong);
else
ele = sdsnewlen((char*)vstr,vlen);

node = zslInsert(zs->zsl,score,ele);
serverAssert(dictAdd(zs->dict,ele,&node->score) == DICT_OK);
zzlNext(zl,&eptr,&sptr);
}
}

zfree(zobj->m_ptr);
zobj->m_ptr = zs;
zobj->encoding = OBJ_ENCODING_SKIPLIST;
Expand Down

0 comments on commit a12dcea

Please sign in to comment.