[asterisk-commits] dlee: branch 12 r399887 - /branches/12/main/channel.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Sep 26 10:41:50 CDT 2013


Author: dlee
Date: Thu Sep 26 10:41:47 2013
New Revision: 399887

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=399887
Log:
Minor performance bump by not allocate manager variable struct if we don't need it

Modified:
    branches/12/main/channel.c

Modified: branches/12/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/main/channel.c?view=diff&rev=399887&r1=399886&r2=399887
==============================================================================
--- branches/12/main/channel.c (original)
+++ branches/12/main/channel.c Thu Sep 26 10:41:47 2013
@@ -7549,14 +7549,19 @@
 	RAII_VAR(struct ast_str *, tmp, NULL, ast_free);
 	struct manager_channel_variable *mcv;
 
+	if (!ret || !tmp) {
+		return NULL;
+	}
+
+	AST_RWLIST_RDLOCK(&channelvars);
+
+	if (AST_LIST_EMPTY(&channelvars)) {
+		return NULL;
+	}
+
 	ret = ao2_alloc(sizeof(*ret), varshead_dtor);
 	tmp = ast_str_create(16);
 
-	if (!ret || !tmp) {
-		return NULL;
-	}
-
-	AST_RWLIST_RDLOCK(&channelvars);
 	AST_LIST_TRAVERSE(&channelvars, mcv, entry) {
 		const char *val = NULL;
 		struct ast_var_t *var;




More information about the asterisk-commits mailing list