From: Timo Sirainen Date: Fri, 17 Sep 2021 13:11:12 +0000 (+0300) Subject: lib: Optimize str_tabescape() X-Git-Tag: 2.3.17~92 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ba465f3a042e74464085768f116dd64437bfa260;p=thirdparty%2Fdovecot%2Fcore.git lib: Optimize str_tabescape() --- diff --git a/src/lib/strescape.c b/src/lib/strescape.c index 54d44ec235..bfa4473c71 100644 --- a/src/lib/strescape.c +++ b/src/lib/strescape.c @@ -172,13 +172,11 @@ const char *str_tabescape(const char *str) string_t *tmp; const char *p; - for (p = str; *p != '\0'; p++) { - if (*p <= '\r') { - tmp = t_str_new(128); - str_append_data(tmp, str, p-str); - str_append_tabescaped(tmp, p); - return str_c(tmp); - } + if ((p = strpbrk(str, "\001\t\r\n")) != NULL) { + tmp = t_str_new(128); + str_append_data(tmp, str, p-str); + str_append_tabescaped(tmp, p); + return str_c(tmp); } return str; }