optimize a bit name completion by avoiding repeated calls to
strlen(word), localize variables and normalize the test for finding the candidate string. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@15516 f38db490-d61c-443f-a65b-d21fe96a405b
This commit is contained in:
parent
7316f249b6
commit
188e4bb75c
|
@ -1552,18 +1552,15 @@ static int action_agent_logoff(struct mansession *s, struct message *m)
|
|||
|
||||
static char *complete_agent_logoff_cmd(const char *line, const char *word, int pos, int state)
|
||||
{
|
||||
struct agent_pvt *p;
|
||||
char name[AST_MAX_AGENT];
|
||||
int which = 0;
|
||||
|
||||
if (pos == 2) {
|
||||
struct agent_pvt *p;
|
||||
char name[AST_MAX_AGENT];
|
||||
int which = 0, len = strlen(word);
|
||||
|
||||
AST_LIST_TRAVERSE(&agents, p, list) {
|
||||
snprintf(name, sizeof(name), "Agent/%s", p->agent);
|
||||
if (!strncasecmp(word, name, strlen(word))) {
|
||||
if (++which > state) {
|
||||
return ast_strdup(name);
|
||||
}
|
||||
}
|
||||
if (!strncasecmp(word, name, len) && ++which > state)
|
||||
return ast_strdup(name);
|
||||
}
|
||||
} else if (pos == 3 && state == 0) {
|
||||
return ast_strdup("soft");
|
||||
|
|
Reference in New Issue