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

[patch] tweak read_successor_candidate_revisions()

From: Daniel Shahaf <danielsh_at_elego.de>
Date: Tue, 13 Sep 2011 07:04:11 +0300

Quick tweak to reduce allocations on this codepath. LINE->data is
a non-const string so we can just parse it in-place without the full
generality of svn_cstring_split().

[[[
Index: subversion/libsvn_fs_fs/fs_fs.c
===================================================================
--- subversion/libsvn_fs_fs/fs_fs.c (revision 1170019)
+++ subversion/libsvn_fs_fs/fs_fs.c (working copy)
@@ -7972,7 +7972,6 @@ read_successor_candidate_revisions(apr_array_heade
       SVN_ERR(svn_stream_readline(stream, &line, "\n", &eof, iterpool));
       if (line->len)
         {
- apr_array_header_t *split;
           const char *pred;
           svn_fs_id_t *pred_id;
           const char *revstr;
@@ -7980,27 +7979,28 @@ read_successor_candidate_revisions(apr_array_heade
 #if SVN_VER_MINOR >=8
           apr_uint64_t rev64;
 #endif
+ const char *p;
 
- split = svn_cstring_split(line->data, " ", TRUE, iterpool);
- if (split->nelts != 2)
+ p = strchr(line->data, ' ');
+ if (p == NULL)
             return svn_error_createf(SVN_ERR_FS_CORRUPT, NULL,
                                      _("Corrupt line '%s' in file '%s'"),
                                      line->data, node_revs_file_abspath);
- pred = APR_ARRAY_IDX(split, 0, const char *);
- pred_id = svn_fs_fs__id_parse(pred, strlen(pred), iterpool);
+ pred = line->data;
+ pred_id = svn_fs_fs__id_parse(pred, p - line->data, iterpool);
           if (pred_id == NULL)
             return svn_error_createf(SVN_ERR_FS_CORRUPT, NULL,
                                       _("Corrupt line '%s' in file '%s'"),
                                       line->data, node_revs_file_abspath);
 
 #if SVN_VER_MINOR >=8
- revstr = APR_ARRAY_IDX(split, 1, const char *);
+ revstr = p+1;
           SVN_ERR(svn_cstring_strtoui64(&rev64, revstr,
                                         0, LONG_MAX,
                                         10 /* base */));
           rev = (long) rev64;
 #else
- revstr = APR_ARRAY_IDX(split, 1, const char *);
+ revstr = p+1;
           rev = apr_atoi64(revstr);
 #endif
 
]]]
Received on 2011-09-13 06:05:12 CEST

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