[Asterisk-code-review] stasis/app.c: Optimize stasis app get debug by name() (asterisk[master])

Richard Mudgett asteriskteam at digium.com
Mon Nov 6 11:50:23 CST 2017


Richard Mudgett has uploaded this change for review. ( https://gerrit.asterisk.org/7018


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/18/7018/1

diff --git a/res/stasis/app.c b/res/stasis/app.c
index b0bcf3c..0b44bf3 100644
--- a/res/stasis/app.c
+++ b/res/stasis/app.c
@@ -871,9 +871,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/7018
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I5f78b7bd6ca7fd2c3b07cbbe036c6a93b4681123
Gerrit-Change-Number: 7018
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/d77239e6/attachment.html>


More information about the asterisk-code-review mailing list