static void listTypeInsert(listTypeEntry *entry, robj *value, int where) {
robj *subject = entry->li->subject;
if (entry->li->encoding == REDIS_ENCODING_ZIPLIST) {
+ value = getDecodedObject(value);
if (where == REDIS_TAIL) {
unsigned char *next = ziplistNext(subject->ptr,entry->zi);
} else {
subject->ptr = ziplistInsert(subject->ptr,entry->zi,value->ptr,sdslen(value->ptr));
}
+ decrRefCount(value);
} else if (entry->li->encoding == REDIS_ENCODING_LIST) {
if (where == REDIS_TAIL) {
listInsertNode(subject->ptr,entry->ln,value,AL_START_TAIL);
assert_equal 8 [r linsert xlist before a aa]
assert_equal 8 [r linsert xlist before bad aaa]
assert_equal {aa a b zz c yy d dd} [r lrange xlist 0 10]
+ assert_equal 9 [r linsert xlist before aa 42]
+ assert_equal 42 [r lrange xlist 0 0]
}
test {LPUSHX, RPUSHX, LPUSHXAFTER, RPUSHXAFTER - regular list} {
assert_equal 8 [r linsert xlist before a aa]
assert_equal 8 [r linsert xlist before bad aaa]
assert_equal {aa a aaaaaaaaaaaaaaaaa zz c yy d dd} [r lrange xlist 0 10]
+ assert_equal 9 [r linsert xlist before aa 42]
+ assert_equal 42 [r lrange xlist 0 0]
}
test {DEL a list - ziplist} {