CVS: winex/dlls/ntdll debugtools.c,1.26,1.27

[email protected] 12 Sep 2007 12:15:42 -0000
Newsgroups gmane.comp.emulators.winex.cvs
Message-ID <[email protected]>
Subject: winex/dlls/ntdll debugtools.c,1.26,1.27Update of /var/lib/cvsd/cvsroot/winex/dlls/ntdll
In directory agravaine:/tmp/cvs-serv6839/dlls/ntdll

Modified Files:
	debugtools.c 
Log Message:

- added a slight optimization to the wine_dbg_vprintf() function.  It just prevents the recalculation of some information that is already known.



Index: debugtools.c
===================================================================
RCS file: /var/lib/cvsd/cvsroot/winex/dlls/ntdll/debugtools.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- debugtools.c	12 Sep 2007 12:14:45 -0000	1.26
+++ debugtools.c	12 Sep 2007 12:15:39 -0000	1.27
@@ -432,18 +432,41 @@
   return buf_orig;
 }
 
+
+/***********************************************************************
+ *		strrevchr (internal)
+ *  finds the character <c> in the string <base> when the end of the
+ *  string is already known.  <end> points to location in the string to
+ *  begin the reverse search at.  <end> must be larger than <base>.
+ *  if <c> is not found in the string NULL is returned.  If <c> is found,
+ *  a pointer to the last occurrence of that character is returned.
+ */
+static char *strrevchr(char *base, char *end, int c){
+    char *pos = end;
+
+
+    for (pos = end; pos >= base; pos--){
+        if (*pos == c)
+            return pos;
+    }
+
+    return NULL;
+}
+
 /***********************************************************************
  *		wine_dbg_vprintf (NTDLL.@)
  */
 int wine_dbg_vprintf( const char *format, va_list args )
 {
-    struct debug_info *info = get_info();
+    struct debug_info *info;
     char *p;
     int ret;
 
     if (!traceEnabled)
         return 0;
 
+    info = get_info();
+
     ret = vsnprintf( info->out_pos, sizeof(info->output) - (info->out_pos - info->output),
                          format, args );
 
@@ -459,7 +482,7 @@
        abort();
     }
 
-    p = strrchr( info->out_pos, '\n' );
+    p = strrevchr( info->out_pos, info->out_pos + ret - 1, '\n' );
     if (!p) info->out_pos += ret;
     else
     {