[Asterisk-code-review] pjsip: Improve CLI completion performance (asterisk[15])
Sean Bright
asteriskteam at digium.com
Fri Dec 8 12:55:08 CST 2017
Sean Bright has uploaded this change for review. ( https://gerrit.asterisk.org/7496
Change subject: pjsip: Improve CLI completion performance
......................................................................
pjsip: Improve CLI completion performance
Use the new ast_cli_completion_add() function to improve completion
performance for commands like 'pjsip show endpoint.'
Change-Id: I76d802294d2ac1766110dc75f7d117c8541ce348
---
M res/res_pjsip/pjsip_cli.c
1 file changed, 6 insertions(+), 12 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/96/7496/1
diff --git a/res/res_pjsip/pjsip_cli.c b/res/res_pjsip/pjsip_cli.c
index 56ec191..c880e2a 100644
--- a/res/res_pjsip/pjsip_cli.c
+++ b/res/res_pjsip/pjsip_cli.c
@@ -84,29 +84,23 @@
static char *complete_show_sorcery_object(struct ao2_container *container,
struct ast_sip_cli_formatter_entry *formatter_entry,
- const char *word, int state)
+ const char *word)
{
- char *result = NULL;
- int wordlen = strlen(word);
- int which = 0;
+ size_t wordlen = strlen(word);
struct ao2_iterator i = ao2_iterator_init(container, 0);
void *object;
while ((object = ao2_t_iterator_next(&i, "iterate thru endpoints table"))) {
const char *id = formatter_entry->get_id(object);
- if (!strncasecmp(word, id, wordlen)
- && ++which > state) {
- result = ast_strdup(id);
+ if (!strncasecmp(word, id, wordlen)) {
+ ast_cli_completion_add(ast_strdup(id));
}
ao2_t_ref(object, -1, "toss iterator endpoint ptr before break");
- if (result) {
- break;
- }
}
ao2_iterator_destroy(&i);
- return result;
+ return NULL;
}
static void dump_str_and_free(int fd, struct ast_str *buf)
@@ -211,7 +205,7 @@
if (cmd == CLI_GENERATE) {
ast_free(context.output_buffer);
- return complete_show_sorcery_object(container, formatter_entry, a->word, a->n);
+ return complete_show_sorcery_object(container, formatter_entry, a->word);
}
if (is_container) {
--
To view, visit https://gerrit.asterisk.org/7496
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 15
Gerrit-MessageType: newchange
Gerrit-Change-Id: I76d802294d2ac1766110dc75f7d117c8541ce348
Gerrit-Change-Number: 7496
Gerrit-PatchSet: 1
Gerrit-Owner: Sean Bright <sean.bright at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20171208/6dc751a0/attachment.html>
More information about the asterisk-code-review
mailing list