From b53e73e159a38308c2873bfce7237b7373ef4374 Mon Sep 17 00:00:00 2001 From: antirez Date: Wed, 14 Dec 2016 12:42:04 +0100 Subject: [PATCH] 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. --- src/cluster.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/cluster.c b/src/cluster.c index b14f7d0d..ddd9937c 100644 --- a/src/cluster.c +++ b/src/cluster.c @@ -4750,7 +4750,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 ... */ @@ -4765,7 +4764,6 @@ void migrateCommand(client *c) { /* Initialization */ copy = 0; replace = 0; - ttl = 0; /* Parse additional options */ for (j = 6; j < c->argc; j++) { @@ -4841,8 +4839,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;