[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: svn commit: r1680819 - /subversion/trunk/subversion/libsvn_fs_fs/revprops.c

From: Ivan Zhakov <ivan_at_visualsvn.com>
Date: Thu, 28 May 2015 16:18:26 +0300

On 28 May 2015 at 16:01, Philip Martin <philip.martin_at_wandisco.com> wrote:
> Ivan Zhakov <ivan_at_visualsvn.com> writes:
>
>> Also I don't understand what do you mean "messy file-based code"? Imho
>> code using svn_stream_write() that require pointer to length is more
>> messy.
>
> "messy" is not my word but the reason I prefer the stream code is that
> we have been moving towards it. Take this change:
>
> - SVN_ERR(svn_stream_printf(stream, pool, "%s\n", filename));
> + SVN_ERR(svn_io_file_write_full(file, filename, strlen(filename),
> + NULL, pool));
> + SVN_ERR(svn_io_file_putc('\n', file, pool));
>
> We have svn_stream_printf() and it makes the stream code neater. We
> could fix that by introducing svn_io_file_printf(). Either we add all
> the neat stream features to the file code or we attempt to move to the
> stream code.
>
I hope you're aware the original code has unbounded memory usage?

But this part of code could be easily rewritten in old fashion with
patch like this:
Index: subversion/libsvn_fs_fs/revprops.c
===================================================================
--- subversion/libsvn_fs_fs/revprops.c (revision 1682076)
+++ subversion/libsvn_fs_fs/revprops.c (working copy)
@@ -1020,16 +1020,14 @@
       *final_path = svn_dirent_join(revprops->folder, PATH_MANIFEST, pool);
       SVN_ERR(svn_io_open_unique_file3(&file, tmp_path, revprops->folder,
                                        svn_io_file_del_none, pool, pool));
-
+ stream = svn_stream_from_aprfile2(file, TRUE, pool);
       for (i = 0; i < revprops->manifest->nelts; ++i)
         {
           const char *filename = APR_ARRAY_IDX(revprops->manifest, i,
                                                const char*);
- SVN_ERR(svn_io_file_write_full(file, filename, strlen(filename),
- NULL, pool));
- SVN_ERR(svn_io_file_putc('\n', file, pool));
+ SVN_ERR(svn_stream_printf(stream, pool, "%s\n", filename));
         }
-
+ SVN_ERR(svn_stream_close(stream));
       SVN_ERR(svn_io_file_flush_to_disk(file, pool));
       SVN_ERR(svn_io_file_close(file, pool));
     }

-- 
Ivan Zhakov
Received on 2015-05-28 15:19:02 CEST

This is an archived mail posted to the Subversion Dev mailing list.