]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: str_tabunescape() - optimize initial escape char lookup
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Fri, 3 Nov 2017 23:35:44 +0000 (01:35 +0200)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Tue, 7 Nov 2017 19:17:27 +0000 (21:17 +0200)
strchr() is faster than looping ourself.

src/lib/strescape.c

index eec040cba0070d88413d90654fd5cc43724de485..3a7968ad41ef43b98bda0d1297b75b9ed8c9930c 100644 (file)
@@ -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++) {