[Asterisk-code-review] json.c: improve ast json to ast variables performance (asterisk[13])

Kevin Harwell asteriskteam at digium.com
Wed Jul 25 15:36:45 CDT 2018


Kevin Harwell has uploaded this change for review. ( https://gerrit.asterisk.org/9690


Change subject: json.c: improve ast_json_to_ast_variables performance
......................................................................

json.c: improve ast_json_to_ast_variables performance

When converting from a json object to an ast variables list the conversion
algorithm was doing a complete traversal of the entire variables list for
every item appended from the json structure.

This patch makes it so the list is no longer traversed for each new ast
variable being appended.

Change-Id: I8bf496a1fc449485150d6db36bfc0354934a3977
---
M main/json.c
1 file changed, 2 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/90/9690/1

diff --git a/main/json.c b/main/json.c
index 1837b5b..0cfeac8 100644
--- a/main/json.c
+++ b/main/json.c
@@ -1046,6 +1046,7 @@
 enum ast_json_to_ast_vars_code ast_json_to_ast_variables(struct ast_json *json_variables, struct ast_variable **variables)
 {
 	struct ast_json_iter *it_json_var;
+	struct ast_variable *tail = NULL;
 
 	*variables = NULL;
 
@@ -1082,7 +1083,7 @@
 			return AST_JSON_TO_AST_VARS_CODE_OOM;
 		}
 
-		ast_variable_list_append(variables, new_var);
+		tail = ast_variable_list_append_hint(variables, tail, new_var);
 	}
 
 	return AST_JSON_TO_AST_VARS_CODE_SUCCESS;

-- 
To view, visit https://gerrit.asterisk.org/9690
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-MessageType: newchange
Gerrit-Change-Id: I8bf496a1fc449485150d6db36bfc0354934a3977
Gerrit-Change-Number: 9690
Gerrit-PatchSet: 1
Gerrit-Owner: Kevin Harwell <kharwell at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180725/ba7c5f49/attachment.html>


More information about the asterisk-code-review mailing list