From: Aki Tuomi Date: Mon, 14 Aug 2017 11:48:05 +0000 (+0300) Subject: auth: Use strchr to split encoding and scheme X-Git-Tag: 2.3.0.rc1~1171 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=512e3c94f603df12426158074a6bf729929c0b75;p=thirdparty%2Fdovecot%2Fcore.git auth: Use strchr to split encoding and scheme This is an optimization because usually strchr is faster --- diff --git a/src/auth/password-scheme.c b/src/auth/password-scheme.c index 8b6956f73c..f64cbcbbc9 100644 --- a/src/auth/password-scheme.c +++ b/src/auth/password-scheme.c @@ -37,16 +37,11 @@ password_scheme_lookup(const char *name, enum password_encoding *encoding_r) { const struct password_scheme *scheme; const char *encoding = NULL; - size_t scheme_len; *encoding_r = PW_ENCODING_NONE; - - for (scheme_len = 0; name[scheme_len] != '\0'; scheme_len++) { - if (name[scheme_len] == '.') { - encoding = name + scheme_len + 1; - name = t_strndup(name, scheme_len); - break; - } + if ((encoding = strchr(name, '.')) != NULL) { + name = t_strdup_until(name, encoding); + encoding++; } scheme = password_scheme_lookup_name(name);