From: Richard Mudgett Date: Fri, 3 Nov 2017 21:14:15 +0000 (-0500) Subject: stasis/app.c: Optimize stasis_app_get_debug_by_name() X-Git-Tag: 13.19.0-rc1~161^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=33d02f509045b2c5bc05f26db7f3ef232fc021c2;p=thirdparty%2Fasterisk.git 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 --- diff --git a/res/stasis/app.c b/res/stasis/app.c index e122f34a49..7d88c1b6ef 100644 --- a/res/stasis/app.c +++ b/res/stasis/app.c @@ -874,9 +874,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)