[asterisk-commits] trunk - r7667 /trunk/apps/app_queue.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Thu Dec 29 02:15:50 CST 2005


Author: russell
Date: Thu Dec 29 02:15:48 2005
New Revision: 7667

URL: http://svn.digium.com/view/asterisk?rev=7667&view=rev
Log:
avoid multiple strlen calls in complete_queue

Modified:
    trunk/apps/app_queue.c

Modified: trunk/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_queue.c?rev=7667&r1=7666&r2=7667&view=diff
==============================================================================
--- trunk/apps/app_queue.c (original)
+++ trunk/apps/app_queue.c Thu Dec 29 02:15:48 2005
@@ -3360,17 +3360,22 @@
 static char *complete_queue(char *line, char *word, int pos, int state)
 {
 	struct ast_call_queue *q;
-	int which=0;
+	char *ret = NULL;
+	int which = 0;
+	int wordlen = strlen(word);
 	
 	ast_mutex_lock(&qlock);
 	for (q = queues; q; q = q->next) {
-		if (!strncasecmp(word, q->name, strlen(word))) {
-			if (++which > state)
+		if (!strncasecmp(word, q->name, wordlen)) {
+			if (++which > state) {
+				ret = strdup(q->name);	
 				break;
+			}
 		}
 	}
 	ast_mutex_unlock(&qlock);
-	return q ? strdup(q->name) : NULL;
+
+	return ret;
 }
 
 /*!\brief callback to display queues status in manager 



More information about the asterisk-commits mailing list