<p>Joshua Colp <strong>submitted</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/15741">View Change</a></p><div style="white-space:pre-wrap">Approvals:
Joshua Colp: Looks good to me, but someone else must approve; Approved for Submit
Kevin Harwell: Looks good to me, approved
George Joseph: Looks good to me, but someone else must approve
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">loader.c: Speed up deprecation metadata lookup<br><br>Only use an XPath query once per module, then just navigate the DOM for<br>everything else.<br><br>Change-Id: Ia0336a7185f9180ccba4b6f631a00f9a22a36e92<br>---<br>M main/loader.c<br>1 file changed, 28 insertions(+), 23 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/main/loader.c b/main/loader.c</span><br><span>index f06016c..aafcd3b 100644</span><br><span>--- a/main/loader.c</span><br><span>+++ b/main/loader.c</span><br><span>@@ -2422,33 +2422,38 @@</span><br><span> continue;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- results = ast_xmldoc_query("/docs/module[@name='%s']/deprecated_in", mod_name);</span><br><span style="color: hsl(0, 100%, 40%);">- deprecated_in[0] = '\0';</span><br><span style="color: hsl(0, 100%, 40%);">- if (results) {</span><br><span style="color: hsl(0, 100%, 40%);">- const char *result_tmp = ast_xml_get_text(ast_xml_xpath_get_first_result(results));</span><br><span style="color: hsl(0, 100%, 40%);">- if (!ast_strlen_zero(result_tmp)) {</span><br><span style="color: hsl(0, 100%, 40%);">- ast_copy_string(deprecated_in, result_tmp, sizeof(deprecated_in));</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">- ast_xml_xpath_results_free(results);</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(120, 100%, 40%);">+ /* Clear out the previous values */</span><br><span style="color: hsl(120, 100%, 40%);">+ deprecated_in[0] = removed_in[0] = replacement[0] = 0;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- results = ast_xmldoc_query("/docs/module[@name='%s']/removed_in", mod_name);</span><br><span style="color: hsl(0, 100%, 40%);">- removed_in[0] = '\0';</span><br><span style="color: hsl(120, 100%, 40%);">+ results = ast_xmldoc_query("/docs/module[@name='%s']", mod_name);</span><br><span> if (results) {</span><br><span style="color: hsl(0, 100%, 40%);">- const char *result_tmp = ast_xml_get_text(ast_xml_xpath_get_first_result(results));</span><br><span style="color: hsl(0, 100%, 40%);">- if (!ast_strlen_zero(result_tmp)) {</span><br><span style="color: hsl(0, 100%, 40%);">- ast_copy_string(removed_in, result_tmp, sizeof(removed_in));</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">- ast_xml_xpath_results_free(results);</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(120, 100%, 40%);">+ struct ast_xml_node *deprecated_node, *removed_node, *replacement_node;</span><br><span style="color: hsl(120, 100%, 40%);">+ struct ast_xml_node *metadata_nodes = ast_xml_node_get_children(ast_xml_xpath_get_first_result(results));</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- results = ast_xmldoc_query("/docs/module[@name='%s']/replacement", mod_name);</span><br><span style="color: hsl(0, 100%, 40%);">- replacement[0] = '\0';</span><br><span style="color: hsl(0, 100%, 40%);">- if (results) {</span><br><span style="color: hsl(0, 100%, 40%);">- const char *result_tmp = ast_xml_get_text(ast_xml_xpath_get_first_result(results));</span><br><span style="color: hsl(0, 100%, 40%);">- if (!ast_strlen_zero(result_tmp)) {</span><br><span style="color: hsl(0, 100%, 40%);">- ast_copy_string(replacement, result_tmp, sizeof(replacement));</span><br><span style="color: hsl(120, 100%, 40%);">+ deprecated_node = ast_xml_find_element(metadata_nodes, "deprecated_in", NULL, NULL);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (deprecated_node) {</span><br><span style="color: hsl(120, 100%, 40%);">+ const char *result_tmp = ast_xml_get_text(deprecated_node);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!ast_strlen_zero(result_tmp)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_copy_string(deprecated_in, result_tmp, sizeof(deprecated_in));</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span> }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ removed_node = ast_xml_find_element(metadata_nodes, "removed_in", NULL, NULL);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (removed_node) {</span><br><span style="color: hsl(120, 100%, 40%);">+ const char *result_tmp = ast_xml_get_text(removed_node);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!ast_strlen_zero(result_tmp)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_copy_string(removed_in, result_tmp, sizeof(removed_in));</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ replacement_node = ast_xml_find_element(metadata_nodes, "replacement", NULL, NULL);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (replacement_node) {</span><br><span style="color: hsl(120, 100%, 40%);">+ const char *result_tmp = ast_xml_get_text(replacement_node);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!ast_strlen_zero(result_tmp)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_copy_string(replacement, result_tmp, sizeof(replacement));</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> ast_xml_xpath_results_free(results);</span><br><span> }</span><br><span> </span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/15741">change 15741</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/asterisk/+/15741"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: Ia0336a7185f9180ccba4b6f631a00f9a22a36e92 </div>
<div style="display:none"> Gerrit-Change-Number: 15741 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: Sean Bright <sean.bright@gmail.com> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@sangoma.com> </div>
<div style="display:none"> Gerrit-Reviewer: Kevin Harwell <kharwell@digium.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>