<p>Sean Bright has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/7495">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">pjsip: Improve CLI completion performance<br><br>Use the new ast_cli_completion_add() function to improve completion<br>performance for commands like 'pjsip show endpoint.'<br><br>Change-Id: I76d802294d2ac1766110dc75f7d117c8541ce348<br>---<br>M res/res_pjsip/pjsip_cli.c<br>1 file changed, 6 insertions(+), 12 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/95/7495/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/res/res_pjsip/pjsip_cli.c b/res/res_pjsip/pjsip_cli.c<br>index 56ec191..c880e2a 100644<br>--- a/res/res_pjsip/pjsip_cli.c<br>+++ b/res/res_pjsip/pjsip_cli.c<br>@@ -84,29 +84,23 @@<br> <br> static char *complete_show_sorcery_object(struct ao2_container *container,<br> struct ast_sip_cli_formatter_entry *formatter_entry,<br>- const char *word, int state)<br>+ const char *word)<br> {<br>- char *result = NULL;<br>- int wordlen = strlen(word);<br>- int which = 0;<br>+ size_t wordlen = strlen(word);<br> <br> struct ao2_iterator i = ao2_iterator_init(container, 0);<br> void *object;<br> <br> while ((object = ao2_t_iterator_next(&i, "iterate thru endpoints table"))) {<br> const char *id = formatter_entry->get_id(object);<br>- if (!strncasecmp(word, id, wordlen)<br>- && ++which > state) {<br>- result = ast_strdup(id);<br>+ if (!strncasecmp(word, id, wordlen)) {<br>+ ast_cli_completion_add(ast_strdup(id));<br> }<br> ao2_t_ref(object, -1, "toss iterator endpoint ptr before break");<br>- if (result) {<br>- break;<br>- }<br> }<br> ao2_iterator_destroy(&i);<br> <br>- return result;<br>+ return NULL;<br> }<br> <br> static void dump_str_and_free(int fd, struct ast_str *buf)<br>@@ -211,7 +205,7 @@<br> <br> if (cmd == CLI_GENERATE) {<br> ast_free(context.output_buffer);<br>- return complete_show_sorcery_object(container, formatter_entry, a->word, a->n);<br>+ return complete_show_sorcery_object(container, formatter_entry, a->word);<br> }<br> <br> if (is_container) {<br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/7495">change 7495</a>. To unsubscribe, 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/7495"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 13 </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I76d802294d2ac1766110dc75f7d117c8541ce348 </div>
<div style="display:none"> Gerrit-Change-Number: 7495 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Sean Bright <sean.bright@gmail.com> </div>