mirror of https://mirror.osredm.com/root/redis.git
Merge 5936f8a514
into a0b22576b8
This commit is contained in:
commit
f33edeb6fc
|
@ -920,9 +920,13 @@ int hashTypeSet(redisDb *db, robj *o, sds field, sds value, int flags) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!update) {
|
if (!update) {
|
||||||
|
listpackEntry entries[2] = {
|
||||||
|
{.sval = (unsigned char*) field, .slen = sdslen(field)},
|
||||||
|
{.sval = (unsigned char*) value, .slen = sdslen(value)},
|
||||||
|
};
|
||||||
|
|
||||||
/* Push new field/value pair onto the tail of the listpack */
|
/* Push new field/value pair onto the tail of the listpack */
|
||||||
zl = lpAppend(zl, (unsigned char*)field, sdslen(field));
|
zl = lpBatchAppend(zl, entries, 2);
|
||||||
zl = lpAppend(zl, (unsigned char*)value, sdslen(value));
|
|
||||||
}
|
}
|
||||||
o->ptr = zl;
|
o->ptr = zl;
|
||||||
|
|
||||||
|
|
30
src/t_zset.c
30
src/t_zset.c
|
@ -1075,29 +1075,29 @@ unsigned char *zzlDelete(unsigned char *zl, unsigned char *eptr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char *zzlInsertAt(unsigned char *zl, unsigned char *eptr, sds ele, double score) {
|
unsigned char *zzlInsertAt(unsigned char *zl, unsigned char *eptr, sds ele, double score) {
|
||||||
unsigned char *sptr;
|
|
||||||
char scorebuf[MAX_D2STRING_CHARS];
|
char scorebuf[MAX_D2STRING_CHARS];
|
||||||
int scorelen = 0;
|
int scorelen = 0;
|
||||||
long long lscore;
|
long long lscore;
|
||||||
int score_is_long = double2ll(score, &lscore);
|
int score_is_long = double2ll(score, &lscore);
|
||||||
if (!score_is_long)
|
if (!score_is_long)
|
||||||
scorelen = d2string(scorebuf,sizeof(scorebuf),score);
|
scorelen = d2string(scorebuf,sizeof(scorebuf),score);
|
||||||
if (eptr == NULL) {
|
|
||||||
zl = lpAppend(zl,(unsigned char*)ele,sdslen(ele));
|
|
||||||
if (score_is_long)
|
|
||||||
zl = lpAppendInteger(zl,lscore);
|
|
||||||
else
|
|
||||||
zl = lpAppend(zl,(unsigned char*)scorebuf,scorelen);
|
|
||||||
} else {
|
|
||||||
/* Insert member before the element 'eptr'. */
|
|
||||||
zl = lpInsertString(zl,(unsigned char*)ele,sdslen(ele),eptr,LP_BEFORE,&sptr);
|
|
||||||
|
|
||||||
/* Insert score after the member. */
|
listpackEntry entries[2];
|
||||||
if (score_is_long)
|
entries[0].sval = (unsigned char*)ele;
|
||||||
zl = lpInsertInteger(zl,lscore,sptr,LP_AFTER,NULL);
|
entries[0].slen = sdslen(ele);
|
||||||
else
|
if (score_is_long) {
|
||||||
zl = lpInsertString(zl,(unsigned char*)scorebuf,scorelen,sptr,LP_AFTER,NULL);
|
entries[1].sval = NULL;
|
||||||
|
entries[1].lval = lscore;
|
||||||
|
} else {
|
||||||
|
entries[1].sval = (unsigned char*)scorebuf;
|
||||||
|
entries[1].slen = scorelen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (eptr == NULL)
|
||||||
|
zl = lpBatchAppend(zl, entries, 2);
|
||||||
|
else
|
||||||
|
zl = lpBatchInsert(zl, eptr, LP_BEFORE, entries, 2, NULL);
|
||||||
|
|
||||||
return zl;
|
return zl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue