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

Joshua Colp asteriskteam at digium.com
Tue Nov 7 07:57:41 CST 2017


Joshua Colp has submitted this change and it was merged. ( 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(-)

Approvals:
  Sean Bright: Looks good to me, but someone else must approve
  Corey Farrell: Looks good to me, but someone else must approve
  Joshua Colp: Looks good to me, approved; Approved for Submit



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: merged
Gerrit-Change-Id: I5f78b7bd6ca7fd2c3b07cbbe036c6a93b4681123
Gerrit-Change-Number: 7018
Gerrit-PatchSet: 1
Gerrit-Owner: Richard Mudgett <rmudgett at digium.com>
Gerrit-Reviewer: Corey Farrell <git at cfware.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Sean Bright <sean.bright at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20171107/282b86b4/attachment.html>


More information about the asterisk-code-review mailing list