summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzuul <zuul@gerrit.asterisk.org>2017-04-11 20:12:55 -0500
committerGerrit Code Review <gerrit2@gerrit.digium.api>2017-04-11 20:12:55 -0500
commit3c32680a8a32e2595913280525c67dcd56902796 (patch)
tree0f59d5c04f025b43919313d67c2848de8efa4a50
parentecde4f15939fc9d6a33842ce6973f28d3a6ba200 (diff)
parent8d323c74fa60fd1eb411336753ef4052faf7b309 (diff)
Merge "sorcery.c: Speed up ast_sorcery_retrieve_by_id()"
-rw-r--r--main/sorcery.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/main/sorcery.c b/main/sorcery.c
index 51b0b22be..0bb2826c8 100644
--- a/main/sorcery.c
+++ b/main/sorcery.c
@@ -1877,12 +1877,17 @@ static int sorcery_cache_create(void *obj, void *arg, int flags)
void *ast_sorcery_retrieve_by_id(const struct ast_sorcery *sorcery, const char *type, const char *id)
{
- RAII_VAR(struct ast_sorcery_object_type *, object_type, ao2_find(sorcery->types, type, OBJ_KEY), ao2_cleanup);
+ struct ast_sorcery_object_type *object_type;
void *object = NULL;
int i;
unsigned int cached = 0;
- if (!object_type || ast_strlen_zero(id)) {
+ if (ast_strlen_zero(id)) {
+ return NULL;
+ }
+
+ object_type = ao2_find(sorcery->types, type, OBJ_SEARCH_KEY);
+ if (!object_type) {
return NULL;
}
@@ -1910,6 +1915,7 @@ void *ast_sorcery_retrieve_by_id(const struct ast_sorcery *sorcery, const char *
}
AST_VECTOR_RW_UNLOCK(&object_type->wizards);
+ ao2_ref(object_type, -1);
return object;
}