Skip to content

Commit 2afe994

Browse files
hanxizh9910ranshid
andauthored
Update src/t_hash.c
Co-authored-by: Ran Shidlansik <ranshid@amazon.com> Signed-off-by: Hanxi Zhang <hanxizh@amazon.com>
1 parent 8b609fc commit 2afe994

1 file changed

Lines changed: 6 additions & 14 deletions

File tree

src/t_hash.c

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,15 +1276,8 @@ void hsetexCommand(client *c) {
12761276
} else if (need_rewrite_for_nx_xx_fnx_fxx_ex_px_exat) {
12771277
/* We use new_argv for rewrite */
12781278
new_argv = zmalloc(sizeof(robj *) * c->argc);
1279-
int j = 0;
1280-
// Command
1281-
new_argv[j++] = c->argv[0];
1282-
incrRefCount(c->argv[0]);
1283-
// Key
1284-
new_argv[j++] = c->argv[1];
1285-
incrRefCount(c->argv[1]);
12861279
// Copy optional args (skip NX/XX/FNX/FXX)
1287-
for (int i = 2; i < fields_index; i++) {
1280+
for (int i = 0; i < fields_index; i++) {
12881281
if (strcmp(c->argv[i]->ptr, "NX") &&
12891282
strcmp(c->argv[i]->ptr, "XX") &&
12901283
strcmp(c->argv[i]->ptr, "FNX") &&
@@ -1293,15 +1286,14 @@ void hsetexCommand(client *c) {
12931286
* EX/PX/EXAT flag. */
12941287
if (expire && !(flags & ARGS_PXAT) && c->argv[i + 1] == expire) {
12951288
robj *milliseconds_obj = createStringObjectFromLongLong(when);
1296-
rewriteClientCommandArgument(c, i, shared.pxat);
1297-
rewriteClientCommandArgument(c, i + 1, milliseconds_obj);
1298-
decrRefCount(milliseconds_obj);
1289+
new_argv[new_argc++] = shared.pxat;
1290+
new_argv[new_argc++] = milliseconds_obj;
1291+
} else {
1292+
new_argv[new_argc++] = c->argv[i];
1293+
incrRefCount(c->argv[i]);
12991294
}
1300-
new_argv[j++] = c->argv[i];
1301-
incrRefCount(c->argv[i]);
13021295
}
13031296
}
1304-
new_argc = j;
13051297
}
13061298

13071299
for (i = fields_index; i < c->argc; i += 2) {

0 commit comments

Comments
 (0)