diff options
author | Richard Mudgett <rmudgett@digium.com> | 2017-11-03 16:14:15 -0500 |
---|---|---|
committer | Richard Mudgett <rmudgett@digium.com> | 2017-11-06 12:50:23 -0500 |
commit | 9771f089f5fc32f4a21d132a7d1fda5835e5632f (patch) | |
tree | b5e95b0d3c45cc4a5916bd65f5ed170449b05803 /res/stasis | |
parent | 21d408a942c45545363486cb37a01210a6e252b6 (diff) |
stasis/app.c: Optimize stasis_app_get_debug_by_name()
* Eliminate RAII_VAR()
* Short circuit application name lookup if global debug enabled.
Change-Id: I5f78b7bd6ca7fd2c3b07cbbe036c6a93b4681123
Diffstat (limited to 'res/stasis')
-rw-r--r-- | res/stasis/app.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/res/stasis/app.c b/res/stasis/app.c index b0bcf3c42..0b44bf3c6 100644 --- a/res/stasis/app.c +++ b/res/stasis/app.c @@ -871,9 +871,21 @@ int stasis_app_get_debug(struct stasis_app *app) int stasis_app_get_debug_by_name(const char *app_name) { - RAII_VAR(struct stasis_app *, app, stasis_app_get_by_name(app_name), ao2_cleanup); + int debug_enabled = 0; - return (app ? app->debug : 0) || global_debug; + if (global_debug) { + debug_enabled = 1; + } else { + struct stasis_app *app = stasis_app_get_by_name(app_name); + + if (app) { + if (app->debug) { + debug_enabled = 1; + } + ao2_ref(app, -1); + } + } + return debug_enabled; } void stasis_app_set_global_debug(int debug) |