From 382991f82ee1cc213e4225ce5f28284974715def Mon Sep 17 00:00:00 2001 From: antirez Date: Mon, 11 Jul 2016 19:18:17 +0200 Subject: [PATCH] Remove useless memmove() from freeMemoryIfNeeded(). We start from the end of the pool to the initial item, zero-ing every entry we use or every ghost entry, there is nothing to memmove since to the right everything should be already set to NULL. --- src/evict.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/evict.c b/src/evict.c index c35b10b8f..bc3c9de24 100644 --- a/src/evict.c +++ b/src/evict.c @@ -264,13 +264,8 @@ int freeMemoryIfNeeded(void) { /* Remove the entry from the pool. */ sdsfree(pool[k].key); - /* Shift all elements on its right to left. */ - memmove(pool+k,pool+k+1, - sizeof(pool[0])*(MAXMEMORY_EVICTION_POOL_SIZE-k-1)); - /* Clear the element on the right which is empty - * since we shifted one position to the left. */ - pool[MAXMEMORY_EVICTION_POOL_SIZE-1].key = NULL; - pool[MAXMEMORY_EVICTION_POOL_SIZE-1].idle = 0; + pool[k].key = NULL; + pool[k].idle = 0; /* If the key exists, is our pick. Otherwise it is * a ghost and we need to try the next element. */