From 164d6a7bf5a690b73ea99f72c410272aec4863d2 Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Sun, 2 Mar 2014 09:43:02 +0000 Subject: [PATCH] Optimize switch_split_user_domain a bit This avoids searching the string repeatedly with strchr. --- src/switch_utils.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/switch_utils.c b/src/switch_utils.c index 9792b4a68c..4e9ca5b8e0 100644 --- a/src/switch_utils.c +++ b/src/switch_utils.c @@ -3127,9 +3127,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;