summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2016-07-08 14:17:11 +0200
committerantirez <antirez@gmail.com>2016-07-12 12:05:45 +0200
commit3b9495d20d7deaddb235e1f82bf4ec922a75a030 (patch)
tree632af6bd7ca811abd5e18c73b629032ef7d092c0
parent2a1247309a63dc5a0e1593a3a89b78c0e17645d2 (diff)
downloadredis-3b9495d20d7deaddb235e1f82bf4ec922a75a030.tar.gz
LRU: use C99 variable len stack array in evictionPoolPopulate().
-rw-r--r--src/evict.c12
1 files changed, 1 insertions, 11 deletions
diff --git a/src/evict.c b/src/evict.c
index bc3c9de24..dbec6b4b5 100644
--- a/src/evict.c
+++ b/src/evict.c
@@ -115,16 +115,7 @@ struct evictionPoolEntry *evictionPoolAlloc(void) {
#define EVICTION_SAMPLES_ARRAY_SIZE 16
void evictionPoolPopulate(dict *sampledict, dict *keydict, struct evictionPoolEntry *pool) {
int j, k, count;
- dictEntry *_samples[EVICTION_SAMPLES_ARRAY_SIZE];
- dictEntry **samples;
-
- /* Try to use a static buffer: this function is a big hit...
- * Note: it was actually measured that this helps. */
- if (server.maxmemory_samples <= EVICTION_SAMPLES_ARRAY_SIZE) {
- samples = _samples;
- } else {
- samples = zmalloc(sizeof(samples[0])*server.maxmemory_samples);
- }
+ dictEntry *samples[server.maxmemory_samples];
count = dictGetSomeKeys(sampledict,samples,server.maxmemory_samples);
for (j = 0; j < count; j++) {
@@ -175,7 +166,6 @@ void evictionPoolPopulate(dict *sampledict, dict *keydict, struct evictionPoolEn
pool[k].key = sdsdup(key);
pool[k].idle = idle;
}
- if (samples != _samples) zfree(samples);
}
int freeMemoryIfNeeded(void) {