]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: str_parse/to_*int*() - minor optimization
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Sun, 5 Nov 2017 19:36:55 +0000 (21:36 +0200)
committerAki Tuomi <aki.tuomi@dovecot.fi>
Mon, 6 Nov 2017 07:34:32 +0000 (09:34 +0200)
src/lib/strnum.c

index b799269410263afc92c0d7fac01e37cab9dfe4ba..7fb57b99e70dff04277b9056e1514517b437c918 100644 (file)
@@ -87,7 +87,7 @@ int str_parse_uintmax(const char *str, uintmax_t *num_r,
        if (*str < '0' || *str > '9')
                return -1;
 
-       for (; *str >= '0' && *str <= '9'; str++) {
+       do {
                if (n >= ((uintmax_t)-1 / 10)) {
                        if (n > (uintmax_t)-1 / 10)
                                return -1;
@@ -95,7 +95,9 @@ int str_parse_uintmax(const char *str, uintmax_t *num_r,
                                return -1;
                }
                n = n * 10 + (*str - '0');
-       }
+               str++;
+       } while (*str >= '0' && *str <= '9');
+
        if (endp_r != NULL)
                *endp_r = str;
        *num_r = n;