[dovecot-cvs] dovecot/src/lib printf-upper-bound.c,1.2,1.3
    cras at procontrol.fi 
    cras at procontrol.fi
       
    Mon Sep  8 05:14:19 EEST 2003
    
        - Previous message: [dovecot-cvs] 
	dovecot/src/lib-imap imap-date.c,1.6,1.7 imap-date.h,1.2,1.3
 
        - Next message: [dovecot-cvs] 
	dovecot/src/lib failures.c,1.22,1.23 printf-upper-bound.c,1.3,1.4
	printf-upper-bound.h,1.1,1.2 str.c,1.10,1.11 strfuncs.c,1.31,1.32
 
         -  Messages sorted by: 
              [ date ]
              [ thread ]
              [ subject ]
              [ author ]
         
 
       
    
  
Update of /home/cvs/dovecot/src/lib
In directory danu:/tmp/cvs-serv10557/lib
Modified Files:
	printf-upper-bound.c 
Log Message:
minor speedup
Index: printf-upper-bound.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib/printf-upper-bound.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- printf-upper-bound.c	28 Dec 2002 08:01:45 -0000	1.2
+++ printf-upper-bound.c	8 Sep 2003 01:14:17 -0000	1.3
@@ -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;
    
    
        
	- Previous message: [dovecot-cvs] 
	dovecot/src/lib-imap imap-date.c,1.6,1.7 imap-date.h,1.2,1.3
 
	- Next message: [dovecot-cvs] 
	dovecot/src/lib failures.c,1.22,1.23 printf-upper-bound.c,1.3,1.4
	printf-upper-bound.h,1.1,1.2 str.c,1.10,1.11 strfuncs.c,1.31,1.32
 
         -  Messages sorted by: 
              [ date ]
              [ thread ]
              [ subject ]
              [ author ]
         
 
       
More information about the dovecot-cvs
mailing list