subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stef...@apache.org
Subject svn commit: r1325489 - /subversion/trunk/subversion/libsvn_subr/stream.c
Date Thu, 12 Apr 2012 20:21:20 GMT
Author: stefan2
Date: Thu Apr 12 20:21:19 2012
New Revision: 1325489

URL: http://svn.apache.org/viewvc?rev=1325489&view=rev
Log:
Minor optimization: we often call svn_stream_printf with
static strings. Don't call the rather expensive apr_pvsprintf
in that case.

* subversion/libsvn_subr/stream.c
  (svn_stream_printf): don't format static strings

Modified:
    subversion/trunk/subversion/libsvn_subr/stream.c

Modified: subversion/trunk/subversion/libsvn_subr/stream.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/stream.c?rev=1325489&r1=1325488&r2=1325489&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/stream.c (original)
+++ subversion/trunk/subversion/libsvn_subr/stream.c Thu Apr 12 20:21:19 2012
@@ -222,9 +222,15 @@ svn_stream_printf(svn_stream_t *stream,
   va_list ap;
   apr_size_t len;
 
-  va_start(ap, fmt);
-  message = apr_pvsprintf(pool, fmt, ap);
-  va_end(ap);
+  /* any format controls or is this a static string? */
+  if (strchr(fmt, '%'))
+    {
+      va_start(ap, fmt);
+      message = apr_pvsprintf(pool, fmt, ap);
+      va_end(ap);
+    }
+  else
+    message = fmt;
 
   len = strlen(message);
   return svn_stream_write(stream, message, &len);



Mime
View raw message