]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
Optimize switch_split_user_domain a bit
authorTravis Cross <tc@traviscross.com>
Sun, 2 Mar 2014 09:43:02 +0000 (09:43 +0000)
committerTravis Cross <tc@traviscross.com>
Sun, 2 Mar 2014 09:49:21 +0000 (09:49 +0000)
This avoids searching the string repeatedly with strchr.

src/switch_utils.c

index 77c7bd2c1fd07e1ffde09bb04983b609281b3c70..346e75416223e2b69d71db978f1c7e4e62acf030 100644 (file)
@@ -3116,9 +3116,10 @@ SWITCH_DECLARE(int) switch_split_user_domain(char *in, char **user, char **domai
        if ((h = in, p = strchr(h, '@'))) *p = '\0', u = in, h = p+1;
 
        /* Clean out the host part of any suffix */
-       if ((p = strchr(h, ':'))) *p = '\0';
-       if ((p = strchr(h, ';'))) *p = '\0';
-       if ((p = strchr(h, ' '))) *p = '\0';
+       for (p = h; *p; p++)
+               if (*p == ':' || *p == ';' || *p == ' ') {
+                       *p = '\0'; break;
+               }
 
        if (user) *user = u;
        if (domain) *domain = h;