From: Timo Sirainen Date: Fri, 3 Nov 2017 23:35:44 +0000 (+0200) Subject: lib: str_tabunescape() - optimize initial escape char lookup X-Git-Tag: 2.2.34~255 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=fc4595194f362ee9be37d56a4652c2b12d63c32f;p=thirdparty%2Fdovecot%2Fcore.git lib: str_tabunescape() - optimize initial escape char lookup strchr() is faster than looping ourself. --- diff --git a/src/lib/strescape.c b/src/lib/strescape.c index eec040cba0..3a7968ad41 100644 --- a/src/lib/strescape.c +++ b/src/lib/strescape.c @@ -201,10 +201,10 @@ char *str_tabunescape(char *str) /* @UNSAFE */ char *dest, *start = str; - while (*str != '\001') { - if (*str == '\0') - return start; - str++; + str = strchr(str, '\001'); + if (str == NULL) { + /* no unescaping needed */ + return start; } for (dest = str; *str != '\0'; str++) {