Mercurial > dovecot > core-2.2
changeset 1762:520e3a0496db HEAD
minor speedup
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Mon, 08 Sep 2003 04:14:17 +0300 |
parents | 3767595e9069 |
children | 32bfcbe2a006 |
files | src/lib/printf-upper-bound.c |
diffstat | 1 files changed, 18 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib/printf-upper-bound.c Mon Sep 08 03:57:36 2003 +0300 +++ b/src/lib/printf-upper-bound.c Mon Sep 08 04:14:17 2003 +0300 @@ -75,11 +75,24 @@ while (*format) { - register char c = *format++; - - if (c != '%') + if (*format++ != '%') len += 1; - else /* (c == '%') */ + else if (*format == 's') + { + /* most commonly used modifier, optimize for it */ + const char *v_string = va_arg (args, const char*); + if (!v_string) + len += 8; /* hold "(null)" */ + else + len += strlen(v_string); + } + else if (*format == 'u') + { + /* second most commonly used modifier */ + (void) va_arg (args, unsigned int); + len += MAX_INT_STRLEN; + } + else { PrintfArgSpec spec; int seen_l = FALSE, conv_done = FALSE; @@ -88,7 +101,7 @@ memset(&spec, 0, sizeof(spec)); do { - c = *format++; + char c = *format++; switch (c) { GDoubleIEEE754 u_double;