You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by ju...@apache.org on 2014/03/04 20:49:29 UTC

svn commit: r1574181 - in /subversion/trunk/subversion/libsvn_repos: delta.c fs-wrap.c hooks.c load-fs-vtable.c log.c replay.c reporter.c rev_hunt.c

Author: julianfoad
Date: Tue Mar  4 19:49:29 2014
New Revision: 1574181

URL: http://svn.apache.org/r1574181
Log:
In libsvn_repos, simplify hash iteration code a little by using key and
value accessor functions rather than apr_hash_this(), as we already do in
many other places.

Though I lament the length of those svn__apr_hash_index_* identifiers (which
I created), at least it's a step closer to readable. We can shorten them
later to apr_hash_this_* by adding configury, now that APR 1.5 has those.

* subversion/libsvn_repos/delta.c
  (delta_dirs): As above.

* subversion/libsvn_repos/fs-wrap.c
  (svn_repos_fs_commit_txn): As above.

* subversion/libsvn_repos/hooks.c
  (lock_token_content): As above.

* subversion/libsvn_repos/load-fs-vtable.c
  (prefix_mergeinfo_paths,
   renumber_mergeinfo_revs,
   remove_node_props): As above.

* subversion/libsvn_repos/log.c
  (svn_repos_check_revision_access,
   turn_moves_into_copies,
   turn_unique_copies_into_moves,
   detect_changed,
   fs_mergeinfo_changed,
   get_combined_mergeinfo_changes,
   send_log,
   combine_mergeinfo_path_lists): As above.

* subversion/libsvn_repos/replay.c
  (add_subdir,
   svn_repos_replay2,
   svn_repos__replay_ev2): As above.

* subversion/libsvn_repos/reporter.c
  (delta_proplists): As above.

* subversion/libsvn_repos/rev_hunt.c
  (find_merged_revisions): As above.

Modified:
    subversion/trunk/subversion/libsvn_repos/delta.c
    subversion/trunk/subversion/libsvn_repos/fs-wrap.c
    subversion/trunk/subversion/libsvn_repos/hooks.c
    subversion/trunk/subversion/libsvn_repos/load-fs-vtable.c
    subversion/trunk/subversion/libsvn_repos/log.c
    subversion/trunk/subversion/libsvn_repos/replay.c
    subversion/trunk/subversion/libsvn_repos/reporter.c
    subversion/trunk/subversion/libsvn_repos/rev_hunt.c

Modified: subversion/trunk/subversion/libsvn_repos/delta.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_repos/delta.c?rev=1574181&r1=1574180&r2=1574181&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_repos/delta.c (original)
+++ subversion/trunk/subversion/libsvn_repos/delta.c Tue Mar  4 19:49:29 2014
@@ -875,10 +875,10 @@ delta_dirs(struct context *c,
      from the target tree. */
   for (hi = apr_hash_first(pool, t_entries); hi; hi = apr_hash_next(hi))
     {
-      const svn_fs_dirent_t *s_entry, *t_entry;
-      const void *key;
-      void *val;
-      apr_ssize_t klen;
+      const void *key = svn__apr_hash_index_key(hi);
+      apr_ssize_t klen = svn__apr_hash_index_klen(hi);
+      const svn_fs_dirent_t *t_entry = svn__apr_hash_index_val(hi);
+      const svn_fs_dirent_t *s_entry;
       const char *t_fullpath;
       const char *e_fullpath;
       const char *s_fullpath;
@@ -887,9 +887,6 @@ delta_dirs(struct context *c,
       /* Clear out our subpool for the next iteration... */
       svn_pool_clear(subpool);
 
-      /* KEY is the entry name in target, VAL the dirent */
-      apr_hash_this(hi, &key, &klen, &val);
-      t_entry = val;
       tgt_kind = t_entry->kind;
       t_fullpath = svn_relpath_join(target_path, t_entry->name, subpool);
       e_fullpath = svn_relpath_join(edit_path, t_entry->name, subpool);
@@ -964,17 +961,13 @@ delta_dirs(struct context *c,
     {
       for (hi = apr_hash_first(pool, s_entries); hi; hi = apr_hash_next(hi))
         {
-          const svn_fs_dirent_t *s_entry;
-          void *val;
+          const svn_fs_dirent_t *s_entry = svn__apr_hash_index_val(hi);
           const char *e_fullpath;
           svn_node_kind_t src_kind;
 
           /* Clear out our subpool for the next iteration... */
           svn_pool_clear(subpool);
 
-          /* KEY is the entry name in source, VAL the dirent */
-          apr_hash_this(hi, NULL, NULL, &val);
-          s_entry = val;
           src_kind = s_entry->kind;
           e_fullpath = svn_relpath_join(edit_path, s_entry->name, subpool);
 

Modified: subversion/trunk/subversion/libsvn_repos/fs-wrap.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_repos/fs-wrap.c?rev=1574181&r1=1574180&r2=1574181&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_repos/fs-wrap.c (original)
+++ subversion/trunk/subversion/libsvn_repos/fs-wrap.c Tue Mar  4 19:49:29 2014
@@ -75,8 +75,7 @@ svn_repos_fs_commit_txn(const char **con
   iterpool = svn_pool_create(pool);
   for (hi = apr_hash_first(pool, props); hi; hi = apr_hash_next(hi))
     {
-      const void *key;
-      apr_hash_this(hi, &key, NULL, NULL);
+      const char *key = svn__apr_hash_index_key(hi);
 
       svn_pool_clear(iterpool);
 
@@ -96,9 +95,8 @@ svn_repos_fs_commit_txn(const char **con
       iterpool = svn_pool_create(pool);
       for (hi = apr_hash_first(pool, props); hi; hi = apr_hash_next(hi))
         {
-          const void *key;
-          void *val;
-          apr_hash_this(hi, &key, NULL, &val);
+          const char *key = svn__apr_hash_index_key(hi);
+          svn_string_t *val = svn__apr_hash_index_val(hi);
 
           svn_pool_clear(iterpool);
 

Modified: subversion/trunk/subversion/libsvn_repos/hooks.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_repos/hooks.c?rev=1574181&r1=1574180&r2=1574181&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_repos/hooks.c (original)
+++ subversion/trunk/subversion/libsvn_repos/hooks.c Tue Mar  4 19:49:29 2014
@@ -520,11 +520,9 @@ lock_token_content(apr_file_t **handle, 
   for (hi = apr_hash_first(pool, lock_tokens); hi;
        hi = apr_hash_next(hi))
     {
-      void *val;
-      const char *path, *token;
+      const char *token = svn__apr_hash_index_key(hi);
+      const char *path = svn__apr_hash_index_val(hi);
 
-      apr_hash_this(hi, (void *)&token, NULL, &val);
-      path = val;
       svn_stringbuf_appendstr(lock_str,
         svn_stringbuf_createf(pool, "%s|%s\n",
                               svn_path_uri_autoescape(path, pool),

Modified: subversion/trunk/subversion/libsvn_repos/load-fs-vtable.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_repos/load-fs-vtable.c?rev=1574181&r1=1574180&r2=1574181&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_repos/load-fs-vtable.c (original)
+++ subversion/trunk/subversion/libsvn_repos/load-fs-vtable.c Tue Mar  4 19:49:29 2014
@@ -202,17 +202,16 @@ prefix_mergeinfo_paths(svn_string_t **me
 {
   apr_hash_t *prefixed_mergeinfo, *mergeinfo;
   apr_hash_index_t *hi;
-  void *rangelist;
 
   SVN_ERR(svn_mergeinfo_parse(&mergeinfo, mergeinfo_orig->data, pool));
   prefixed_mergeinfo = apr_hash_make(pool);
   for (hi = apr_hash_first(pool, mergeinfo); hi; hi = apr_hash_next(hi))
     {
-      const void *key;
-      const char *path, *merge_source;
+      const char *merge_source = svn__apr_hash_index_key(hi);
+      svn_rangelist_t *rangelist = svn__apr_hash_index_val(hi);
+      const char *path;
 
-      apr_hash_this(hi, &key, NULL, &rangelist);
-      merge_source = svn_relpath_canonicalize(key, pool);
+      merge_source = svn_relpath_canonicalize(merge_source, pool);
 
       /* The svn:mergeinfo property syntax demands a repos abspath */
       path = svn_fspath__canonicalize(svn_relpath_join(parent_dir,
@@ -268,16 +267,10 @@ renumber_mergeinfo_revs(svn_string_t **f
 
   for (hi = apr_hash_first(subpool, mergeinfo); hi; hi = apr_hash_next(hi))
     {
-      const char *merge_source;
-      svn_rangelist_t *rangelist;
+      const char *merge_source = svn__apr_hash_index_key(hi);
+      svn_rangelist_t *rangelist = svn__apr_hash_index_val(hi);
       struct parse_baton *pb = rb->pb;
       int i;
-      const void *key;
-      void *val;
-
-      apr_hash_this(hi, &key, NULL, &val);
-      merge_source = key;
-      rangelist = val;
 
       /* Possibly renumber revisions in merge source's rangelist. */
       for (i = 0; i < rangelist->nelts; i++)
@@ -838,9 +831,8 @@ remove_node_props(void *baton)
 
   for (hi = apr_hash_first(nb->pool, proplist); hi; hi = apr_hash_next(hi))
     {
-      const void *key;
+      const char *key = svn__apr_hash_index_key(hi);
 
-      apr_hash_this(hi, &key, NULL, NULL);
       SVN_ERR(change_node_prop(rb->txn_root, nb->path, key, NULL,
                                rb->pb->validate_props, nb->pool));
     }

Modified: subversion/trunk/subversion/libsvn_repos/log.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_repos/log.c?rev=1574181&r1=1574180&r2=1574181&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_repos/log.c (original)
+++ subversion/trunk/subversion/libsvn_repos/log.c Tue Mar  4 19:49:29 2014
@@ -81,14 +81,11 @@ svn_repos_check_revision_access(svn_repo
   subpool = svn_pool_create(pool);
   for (hi = apr_hash_first(pool, changes); hi; hi = apr_hash_next(hi))
     {
-      const void *key;
-      void *val;
-      svn_fs_path_change2_t *change;
+      const char *key = svn__apr_hash_index_key(hi);
+      svn_fs_path_change2_t *change = svn__apr_hash_index_val(hi);
       svn_boolean_t readable;
 
       svn_pool_clear(subpool);
-      apr_hash_this(hi, &key, NULL, &val);
-      change = val;
 
       SVN_ERR(authz_read_func(&readable, rev_root, key,
                               authz_read_baton, subpool));
@@ -175,10 +172,7 @@ turn_moves_into_copies(apr_hash_t *chang
   apr_hash_index_t *hi;
   for (hi = apr_hash_first(pool, changes); hi; hi = apr_hash_next(hi))
     {
-      const char *key;
-      apr_ssize_t klen;
-      svn_log_changed_path2_t *change;
-      apr_hash_this(hi, (const void **)&key, &klen, (void**)&change);
+      svn_log_changed_path2_t *change = svn__apr_hash_index_val(hi);
 
       switch (change->action)
         {
@@ -218,8 +212,7 @@ turn_unique_copies_into_moves(apr_hash_t
 
   for (hi = apr_hash_first(pool, changes); hi; hi = apr_hash_next(hi))
     {
-      svn_log_changed_path2_t *change;
-      apr_hash_this(hi, NULL, NULL, (void**)&change);
+      svn_log_changed_path2_t *change = svn__apr_hash_index_val(hi);
 
       if (change->copyfrom_path && change->copyfrom_rev == revision-1)
         APR_ARRAY_PUSH(copy_sources, const char *)
@@ -258,11 +251,9 @@ turn_unique_copies_into_moves(apr_hash_t
 
   for (hi = apr_hash_first(pool, changes); hi; hi = apr_hash_next(hi))
     {
-      const char *key;
-      apr_ssize_t klen;
-      svn_log_changed_path2_t *change, *copy_from_change;
+      svn_log_changed_path2_t *change = svn__apr_hash_index_val(hi);
+      svn_log_changed_path2_t *copy_from_change;
 
-      apr_hash_this(hi, (const void **)&key, &klen, (void**)&change);
       if (   change->copyfrom_rev != revision-1
           || !change->copyfrom_path
           || !svn_hash_gets(unique_copy_sources, change->copyfrom_path))
@@ -353,17 +344,14 @@ detect_changed(apr_hash_t **changed,
       /* NOTE:  Much of this loop is going to look quite similar to
          svn_repos_check_revision_access(), but we have to do more things
          here, so we'll live with the duplication. */
-      svn_fs_path_change2_t *change;
-      const char *path;
-      apr_ssize_t path_len;
+      const char *path = svn__apr_hash_index_key(hi);
+      apr_ssize_t path_len = svn__apr_hash_index_klen(hi);
+      svn_fs_path_change2_t *change = svn__apr_hash_index_val(hi);
       char action;
       svn_log_changed_path2_t *item;
 
       svn_pool_clear(subpool);
 
-      /* KEY will be the path, VAL the change. */
-      apr_hash_this(hi, (const void **)&path, &path_len, (void **)&change);
-
       /* Skip path if unreadable. */
       if (authz_read_func)
         {
@@ -774,21 +762,15 @@ fs_mergeinfo_changed(svn_mergeinfo_catal
        hi;
        hi = apr_hash_next(hi))
     {
-      const void *key;
-      void *val;
-      svn_fs_path_change2_t *change;
-      const char *changed_path, *base_path = NULL;
+      const char *changed_path = svn__apr_hash_index_key(hi);
+      svn_fs_path_change2_t *change = svn__apr_hash_index_val(hi);
+      const char *base_path = NULL;
       svn_revnum_t base_rev = SVN_INVALID_REVNUM;
       svn_fs_root_t *base_root = NULL;
       svn_string_t *prev_mergeinfo_value = NULL, *mergeinfo_value;
 
       svn_pool_clear(iterpool);
 
-      /* KEY will be the path, VAL the change. */
-      apr_hash_this(hi, &key, NULL, &val);
-      changed_path = key;
-      change = val;
-
       /* If there was no mergeinfo change on this item, ignore it. */
       if (change->mergeinfo_mod == svn_tristate_false)
         continue;
@@ -1133,16 +1115,10 @@ get_combined_mergeinfo_changes(svn_merge
   for (hi = apr_hash_first(scratch_pool, added_mergeinfo_catalog);
        hi; hi = apr_hash_next(hi))
     {
-      const void *key;
-      apr_ssize_t klen;
-      void *val;
-      const char *changed_path;
-      svn_mergeinfo_t added, deleted;
-
-      /* The path is the key, the mergeinfo delta is the value. */
-      apr_hash_this(hi, &key, &klen, &val);
-      changed_path = key;
-      added = val;
+      const char *changed_path = svn__apr_hash_index_key(hi);
+      apr_ssize_t klen = svn__apr_hash_index_klen(hi);
+      svn_mergeinfo_t added = svn__apr_hash_index_val(hi);
+      svn_mergeinfo_t deleted;
 
       for (i = 0; i < paths->nelts; i++)
         {
@@ -1150,7 +1126,7 @@ get_combined_mergeinfo_changes(svn_merge
           if (! svn_fspath__skip_ancestor(path, changed_path))
             continue;
           svn_pool_clear(iterpool);
-          deleted = apr_hash_get(deleted_mergeinfo_catalog, key, klen);
+          deleted = apr_hash_get(deleted_mergeinfo_catalog, changed_path, klen);
           SVN_ERR(svn_mergeinfo_merge2(*deleted_mergeinfo,
                                        svn_mergeinfo_dup(deleted, result_pool),
                                        result_pool, iterpool));
@@ -1375,18 +1351,14 @@ send_log(svn_revnum_t rev,
           const char *changed_path = svn__apr_hash_index_key(hi);
           apr_hash_index_t *hi2;
 
-          apr_hash_this(hi, (const void**)&changed_path, NULL, NULL);
-
           /* Look at each path on the log target's mergeinfo. */
           for (hi2 = apr_hash_first(iterpool,
                                     log_target_history_as_mergeinfo);
                hi2;
                hi2 = apr_hash_next(hi2))
             {
-              const char *mergeinfo_path;
-              svn_rangelist_t *rangelist;
-              apr_hash_this(hi2, (const void**)&mergeinfo_path, NULL,
-                                 (void **)&rangelist);
+              const char *mergeinfo_path = svn__apr_hash_index_key(hi2);
+              svn_rangelist_t *rangelist = svn__apr_hash_index_val(hi2);
 
               /* Check whether CHANGED_PATH at revision REV is a child of
                  a (path, revision) tuple in LOG_TARGET_HISTORY_AS_MERGEINFO. */
@@ -1663,8 +1635,9 @@ combine_mergeinfo_path_lists(apr_array_h
     {
       int i;
       struct rangelist_path *rp = apr_palloc(subpool, sizeof(*rp));
-      apr_hash_this(hi, (void *) &rp->path, NULL,
-                    (void *) &rp->rangelist);
+
+      rp->path = svn__apr_hash_index_key(hi);
+      rp->rangelist = svn__apr_hash_index_val(hi);
       APR_ARRAY_PUSH(rangelist_paths, struct rangelist_path *) = rp;
 
       /* We need to make local copies of the rangelist, since we will be

Modified: subversion/trunk/subversion/libsvn_repos/replay.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_repos/replay.c?rev=1574181&r1=1574180&r2=1574181&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_repos/replay.c (original)
+++ subversion/trunk/subversion/libsvn_repos/replay.c Tue Mar  4 19:49:29 2014
@@ -184,11 +184,10 @@ add_subdir(svn_fs_root_t *source_root,
 
   for (phi = apr_hash_first(pool, props); phi; phi = apr_hash_next(phi))
     {
-      const void *key;
-      void *val;
+      const char *key = svn__apr_hash_index_key(phi);
+      svn_string_t *val = svn__apr_hash_index_val(phi);
 
       svn_pool_clear(subpool);
-      apr_hash_this(phi, &key, NULL, &val);
       SVN_ERR(editor->change_dir_prop(*dir_baton, key, val, subpool));
     }
 
@@ -201,18 +200,13 @@ add_subdir(svn_fs_root_t *source_root,
     {
       svn_fs_path_change2_t *change;
       svn_boolean_t readable = TRUE;
-      svn_fs_dirent_t *dent;
+      svn_fs_dirent_t *dent = svn__apr_hash_index_val(hi);
       const char *copyfrom_path = NULL;
       svn_revnum_t copyfrom_rev = SVN_INVALID_REVNUM;
       const char *new_edit_path;
-      void *val;
 
       svn_pool_clear(subpool);
 
-      apr_hash_this(hi, NULL, NULL, &val);
-
-      dent = val;
-
       new_edit_path = svn_relpath_join(edit_path, dent->name, subpool);
 
       /* If a file or subdirectory of the copied directory is listed as a
@@ -309,9 +303,9 @@ add_subdir(svn_fs_root_t *source_root,
 
           for (phi = apr_hash_first(pool, props); phi; phi = apr_hash_next(phi))
             {
-              const void *key;
+              const char *key = svn__apr_hash_index_key(phi);
+              svn_string_t *val = svn__apr_hash_index_val(phi);
 
-              apr_hash_this(phi, &key, NULL, &val);
               SVN_ERR(editor->change_file_prop(file_baton, key, val, subpool));
             }
 
@@ -883,17 +877,11 @@ svn_repos_replay2(svn_fs_root_t *root,
   changed_paths = apr_hash_make(pool);
   for (hi = apr_hash_first(pool, fs_changes); hi; hi = apr_hash_next(hi))
     {
-      const void *key;
-      void *val;
-      apr_ssize_t keylen;
-      const char *path;
-      svn_fs_path_change2_t *change;
+      const char *path = svn__apr_hash_index_key(hi);
+      apr_ssize_t keylen = svn__apr_hash_index_klen(hi);
+      svn_fs_path_change2_t *change = svn__apr_hash_index_val(hi);
       svn_boolean_t allowed = TRUE;
 
-      apr_hash_this(hi, &key, &keylen, &val);
-      path = key;
-      change = val;
-
       if (authz_read_func)
         SVN_ERR(authz_read_func(&allowed, root, path, authz_read_baton,
                                 pool));
@@ -1515,17 +1503,11 @@ svn_repos__replay_ev2(svn_fs_root_t *roo
   for (hi = apr_hash_first(scratch_pool, fs_changes); hi;
         hi = apr_hash_next(hi))
     {
-      const void *key;
-      void *val;
-      apr_ssize_t keylen;
-      const char *path;
-      svn_fs_path_change2_t *change;
+      const char *path = svn__apr_hash_index_key(hi);
+      apr_ssize_t keylen = svn__apr_hash_index_klen(hi);
+      svn_fs_path_change2_t *change = svn__apr_hash_index_val(hi);
       svn_boolean_t allowed = TRUE;
 
-      apr_hash_this(hi, &key, &keylen, &val);
-      path = key;
-      change = val;
-
       if (authz_read_func)
         SVN_ERR(authz_read_func(&allowed, root, path, authz_read_baton,
                                 scratch_pool));

Modified: subversion/trunk/subversion/libsvn_repos/reporter.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_repos/reporter.c?rev=1574181&r1=1574180&r2=1574181&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_repos/reporter.c (original)
+++ subversion/trunk/subversion/libsvn_repos/reporter.c Tue Mar  4 19:49:29 2014
@@ -603,10 +603,9 @@ delta_proplists(report_baton_t *b, svn_r
       /* So source, i.e. all new.  Transmit all target props. */
       for (hi = apr_hash_first(pool, t_props); hi; hi = apr_hash_next(hi))
         {
-          const void *key;
-          void *val;
+          const char *key = svn__apr_hash_index_key(hi);
+          svn_string_t *val = svn__apr_hash_index_val(hi);
 
-          apr_hash_this(hi, &key, NULL, &val);
           SVN_ERR(change_fn(b, object, key, val, pool));
         }
     }

Modified: subversion/trunk/subversion/libsvn_repos/rev_hunt.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_repos/rev_hunt.c?rev=1574181&r1=1574180&r2=1574181&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_repos/rev_hunt.c (original)
+++ subversion/trunk/subversion/libsvn_repos/rev_hunt.c Tue Mar  4 19:49:29 2014
@@ -1249,16 +1249,14 @@ find_merged_revisions(apr_array_header_t
           for (hi = apr_hash_first(iterpool, old_pr->merged_mergeinfo); hi;
                hi = apr_hash_next(hi))
             {
+              const char *path = svn__apr_hash_index_key(hi);
+              svn_rangelist_t *rangelist = svn__apr_hash_index_val(hi);
               apr_pool_t *iterpool3;
-              svn_rangelist_t *rangelist;
-              const char *path;
               int j;
 
               svn_pool_clear(iterpool2);
               iterpool3 = svn_pool_create(iterpool2);
 
-              apr_hash_this(hi, (void *) &path, NULL, (void *) &rangelist);
-
               for (j = 0; j < rangelist->nelts; j++)
                 {
                   svn_merge_range_t *range = APR_ARRAY_IDX(rangelist, j,