subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From i...@apache.org
Subject svn commit: r1707196 - /subversion/trunk/subversion/libsvn_subr/stream.c
Date Wed, 07 Oct 2015 07:57:06 GMT
Author: ivan
Date: Wed Oct  7 07:57:05 2015
New Revision: 1707196

URL: http://svn.apache.org/viewvc?rev=1707196&view=rev
Log:
Slightly optimize svn_stringbuf_from_stream() to avoid allocating twice
more memory and unnecessary memcpy() when LEN_HINT is equal to final stringbuf
length.

* subversion/libsvn_subr/stream.c
  (svn_stringbuf_from_stream): Always preallocate LEN_HINT + MIN_READ_SIZE
   bytes to be able perform final read without stringbuf reallocation.  

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=1707196&r1=1707195&r2=1707196&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/stream.c (original)
+++ subversion/trunk/subversion/libsvn_subr/stream.c Wed Oct  7 07:57:05 2015
@@ -1490,7 +1490,7 @@ svn_stringbuf_from_stream(svn_stringbuf_
 
   apr_size_t to_read = 0;
   svn_stringbuf_t *text
-    = svn_stringbuf_create_ensure(len_hint ? len_hint : MIN_READ_SIZE,
+    = svn_stringbuf_create_ensure(len_hint + MIN_READ_SIZE,
                                   result_pool);
 
   do



Mime
View raw message