mirror of
https://github.com/fluencelabs/redis
synced 2025-03-21 10:00:51 +00:00
Optimized autoMemoryFreed loop
This commit is contained in:
parent
b09a6b6a5d
commit
46b07cbb5c
@ -580,7 +580,7 @@ void autoMemoryFreed(RedisModuleCtx *ctx, int type, void *ptr) {
|
|||||||
if (!(ctx->flags & REDISMODULE_CTX_AUTO_MEMORY)) return;
|
if (!(ctx->flags & REDISMODULE_CTX_AUTO_MEMORY)) return;
|
||||||
|
|
||||||
int j;
|
int j;
|
||||||
for (j = 0; j < ctx->amqueue_used; j++) {
|
for (j = ctx->amqueue_used - 1; j >= 0; j--) {
|
||||||
if (ctx->amqueue[j].type == type &&
|
if (ctx->amqueue[j].type == type &&
|
||||||
ctx->amqueue[j].ptr == ptr)
|
ctx->amqueue[j].ptr == ptr)
|
||||||
{
|
{
|
||||||
@ -588,6 +588,9 @@ void autoMemoryFreed(RedisModuleCtx *ctx, int type, void *ptr) {
|
|||||||
/* Optimization: if this is the last element, we can
|
/* Optimization: if this is the last element, we can
|
||||||
* reuse it. */
|
* reuse it. */
|
||||||
if (j == ctx->amqueue_used-1) ctx->amqueue_used--;
|
if (j == ctx->amqueue_used-1) ctx->amqueue_used--;
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user