diff options
author | antirez <antirez@gmail.com> | 2016-12-14 12:42:04 +0100 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2016-12-14 12:44:32 +0100 |
commit | 68aab8e8119c37991ac7f10643503f38ad8d25a3 (patch) | |
tree | e6d8e88fa318d23e93b6088e29f46af46335d87d | |
parent | 788e892534c77f785c76bdefba506809310ab12a (diff) | |
download | redis-68aab8e8119c37991ac7f10643503f38ad8d25a3.tar.gz |
MIGRATE: Remove upfront ttl initialization.
After the fix for #3673 the ttl var is always initialized inside the
loop itself, so the early initialization is not needed.
Variables declaration also moved to a more local scope.
-rw-r--r-- | src/cluster.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/cluster.c b/src/cluster.c index f128a9778..24eff50c7 100644 --- a/src/cluster.c +++ b/src/cluster.c @@ -4652,7 +4652,6 @@ void migrateCommand(client *c) { int copy, replace, j; long timeout; long dbid; - long long ttl, expireat; robj **ov = NULL; /* Objects to migrate. */ robj **kv = NULL; /* Key names. */ robj **newargv = NULL; /* Used to rewrite the command as DEL ... keys ... */ @@ -4667,7 +4666,6 @@ void migrateCommand(client *c) { /* Initialization */ copy = 0; replace = 0; - ttl = 0; /* Parse additional options */ for (j = 6; j < c->argc; j++) { @@ -4743,8 +4741,9 @@ try_again: /* Create RESTORE payload and generate the protocol to call the command. */ for (j = 0; j < num_keys; j++) { - ttl = 0; - expireat = getExpire(c->db,kv[j]); + long long ttl = 0; + long long expireat = getExpire(c->db,kv[j]); + if (expireat != -1) { ttl = expireat-mstime(); if (ttl < 1) ttl = 1; |