changeset 22647:641236fac254

lib: str_parse/to_*int*() - minor optimization
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Sun, 05 Nov 2017 21:36:55 +0200
parents 340fd327a965
children 6bd018a94a57
files src/lib/strnum.c
diffstat 1 files changed, 4 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib/strnum.c	Sat Nov 04 15:29:29 2017 +0200
+++ b/src/lib/strnum.c	Sun Nov 05 21:36:55 2017 +0200
@@ -87,7 +87,7 @@
 	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 @@
 				return -1;
 		}
 		n = n * 10 + (*str - '0');
-	}
+		str++;
+	} while (*str >= '0' && *str <= '9');
+
 	if (endp_r != NULL)
 		*endp_r = str;
 	*num_r = n;