Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
137fd86a
Commit
137fd86a
authored
May 19, 2016
by
Dvir Volk
Browse files
optimized amFree even further
parent
46b07cbb
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/module.c
View file @
137fd86a
...
@@ -585,12 +585,17 @@ void autoMemoryFreed(RedisModuleCtx *ctx, int type, void *ptr) {
...
@@ -585,12 +585,17 @@ void autoMemoryFreed(RedisModuleCtx *ctx, int type, void *ptr) {
ctx
->
amqueue
[
j
].
ptr
==
ptr
)
ctx
->
amqueue
[
j
].
ptr
==
ptr
)
{
{
ctx
->
amqueue
[
j
].
type
=
REDISMODULE_AM_FREED
;
ctx
->
amqueue
[
j
].
type
=
REDISMODULE_AM_FREED
;
/* Optimization: if this is the last element, we can
* reuse it. */
/* Switch the freed element and the top element, to avoid growing
if
(
j
==
ctx
->
amqueue_used
-
1
)
ctx
->
amqueue_used
--
;
* the queue unnecessarily if we allocate/free in a loop */
if
(
j
!=
ctx
->
amqueue_used
-
1
)
{
ctx
->
amqueue
[
j
]
=
ctx
->
amqueue
[
ctx
->
amqueue_used
-
1
];
}
/* Reduce the size of the queue because we either moved the top
* element elsewhere or freed it */
ctx
->
amqueue_used
--
;
break
;
break
;
}
}
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment