[Asterisk-code-review] stasis/app.c: Optimize stasis app get debug by name() (asterisk[13])
Richard Mudgett
asteriskteam at digium.com
Mon Nov 6 11:50:01 CST 2017
Richard Mudgett has uploaded this change for review. ( https://gerrit.asterisk.org/7016
Change subject: stasis/app.c: Optimize stasis_app_get_debug_by_name()
......................................................................
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
---
M res/stasis/app.c
1 file changed, 14 insertions(+), 2 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/16/7016/1
diff --git a/res/stasis/app.c b/res/stasis/app.c
index e122f34..7d88c1b 100644
--- a/res/stasis/app.c
+++ b/res/stasis/app.c
@@ -874,9 +874,21 @@
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)
--
To view, visit https://gerrit.asterisk.org/7016
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-MessageType: newchange
Gerrit-Change-Id: I5f78b7bd6ca7fd2c3b07cbbe036c6a93b4681123
Gerrit-Change-Number: 7016
Gerrit-PatchSet: 1
Gerrit-Owner: Richard Mudgett <rmudgett at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20171106/31a94fa7/attachment-0001.html>
More information about the asterisk-code-review
mailing list