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

Re: svn commit: r1554619 - in /subversion/trunk: subversion/include/ subversion/libsvn_client/ subversion/libsvn_fs_fs/ subversion/libsvn_fs_x/ subversion/libsvn_ra/ subversion/libsvn_ra_serf/ subversion/libsvn_repos/ subversion/libsvn_subr/ subversion/lib...

From: Bert Huijben <bert_at_qqmail.nl>
Date: Thu, 2 Jan 2014 10:58:50 +0000

While this does standardize the sort APIs it breaks the common pattern that we are moving to output arguments first. (See the comment at the start of svn_wc for the description of that pattern which we improved over the wc-Ng work)


Bert






Sent from Windows Mail





From: Stefan Fuhrmann
Sent: ‎Wednesday‎, ‎January‎ ‎1‎, ‎2014 ‎2‎:‎58‎ ‎PM
To: commits_at_subversion.apache.org





Author: stefan2
Date: Wed Jan 1 13:58:10 2014
New Revision: 1554619

URL: http://svn.apache.org/r1554619
Log:
svn_sort__* private API normalization. In functions with no return
argument, make the container the first parameter. Update all callers.

* subversion/include/svn_sorts.h
  (svn_sort__bsearch_lower_bound,
   svn_sort__array_insert): Move the ARRAY parameter to the front.

* subversion/libsvn_subr/sorts.c
  (svn_sort__bsearch_lower_bound,
   svn_sort__array_insert): Update implementation signatures.

* subversion/libsvn_client/merge.c
  (slice_remaining_ranges,
   insert_child_to_merge,
   normalize_merge_sources_internal): Update API callers.

* subversion/libsvn_fs_fs/index.c
  (get_p2l_entry_from_cached_page,
   svn_fs_fs__p2l_entry_lookup): Same.

* subversion/libsvn_fs_fs/pack.c
  (find_first_reference): Same.

* subversion/libsvn_fs_fs/transaction.c
  (verify_moves): Same.

* subversion/libsvn_fs_x/index.c
  (get_p2l_entry_from_cached_page,
   p2l_entry_lookup): Same.

* subversion/libsvn_fs_x/transaction.c
  (verify_moves): Same.

* subversion/libsvn_ra/compat.c
  (svn_ra__get_inherited_props_walk): Same.

* subversion/libsvn_ra_serf/inherited_props.c
  (get_iprops_via_more_requests): Same.

* subversion/libsvn_repos/fs-wrap.c
  (svn_repos_fs_get_inherited_props): Same.

* subversion/libsvn_subr/mergeinfo.c
  (adjust_remaining_ranges,
   svn_rangelist_merge2): Same.

* subversion/libsvn_wc/wc_db.c
  (db_read_inherited_props): Same.

* tools/server-side/fsfs-stats.c
  (find_representation,
   parse_representation): And finally the same here.

Modified:
    subversion/trunk/subversion/include/svn_sorts.h
    subversion/trunk/subversion/libsvn_client/merge.c
    subversion/trunk/subversion/libsvn_fs_fs/index.c
    subversion/trunk/subversion/libsvn_fs_fs/pack.c
    subversion/trunk/subversion/libsvn_fs_fs/transaction.c
    subversion/trunk/subversion/libsvn_fs_x/index.c
    subversion/trunk/subversion/libsvn_fs_x/transaction.c
    subversion/trunk/subversion/libsvn_ra/compat.c
    subversion/trunk/subversion/libsvn_ra_serf/inherited_props.c
    subversion/trunk/subversion/libsvn_repos/fs-wrap.c
    subversion/trunk/subversion/libsvn_subr/mergeinfo.c
    subversion/trunk/subversion/libsvn_subr/sorts.c
    subversion/trunk/subversion/libsvn_wc/wc_db.c
    subversion/trunk/tools/server-side/fsfs-stats.c

Modified: subversion/trunk/subversion/include/svn_sorts.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/svn_sorts.h?rev=1554619&r1=1554618&r2=1554619&view=diff
==============================================================================
--- subversion/trunk/subversion/include/svn_sorts.h (original)
+++ subversion/trunk/subversion/include/svn_sorts.h Wed Jan 1 13:58:10 2014
@@ -180,8 +180,8 @@ svn_sort__hash(apr_hash_t *ht,
  * @note Private. For use by Subversion's own code only.
  */
 int
-svn_sort__bsearch_lower_bound(const void *key,
- const apr_array_header_t *array,
+svn_sort__bsearch_lower_bound(const apr_array_header_t *array,
+ const void *key,
                               int (*compare_func)(const void *, const void *));
 
 /* Insert a shallow copy of @a *new_element into the array @a array at the index
@@ -191,8 +191,8 @@ svn_sort__bsearch_lower_bound(const void
  * @note Private. For use by Subversion's own code only.
  */
 void
-svn_sort__array_insert(const void *new_element,
- apr_array_header_t *array,
+svn_sort__array_insert(apr_array_header_t *array,
+ const void *new_element,
                        int insert_index);
 
 

Modified: subversion/trunk/subversion/libsvn_client/merge.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/merge.c?rev=1554619&r1=1554618&r2=1554619&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/merge.c (original)
+++ subversion/trunk/subversion/libsvn_client/merge.c Wed Jan 1 13:58:10 2014
@@ -5828,7 +5828,7 @@ slice_remaining_ranges(apr_array_header_
               split_range2->start = end_rev;
               APR_ARRAY_IDX(child->remaining_ranges, 0,
                             svn_merge_range_t *) = split_range1;
- svn_sort__array_insert(&split_range2, child->remaining_ranges, 1);
+ svn_sort__array_insert(child->remaining_ranges, &split_range2, 1);
             }
         }
     }
@@ -5963,11 +5963,11 @@ insert_child_to_merge(apr_array_header_t
 
   /* Find where to insert the new element */
   insert_index =
- svn_sort__bsearch_lower_bound(&insert_element, children_with_mergeinfo,
+ svn_sort__bsearch_lower_bound(children_with_mergeinfo, &insert_element,
                                   compare_merge_path_t_as_paths);
 
   new_element = svn_client__merge_path_dup(insert_element, pool);
- svn_sort__array_insert(&new_element, children_with_mergeinfo, insert_index);
+ svn_sort__array_insert(children_with_mergeinfo, &new_element, insert_index);
 }
 
 /* Helper for get_mergeinfo_paths().
@@ -7065,7 +7065,7 @@ normalize_merge_sources_internal(apr_arr
                   new_segment->path = original_repos_relpath;
                   new_segment->range_start = original_revision;
                   new_segment->range_end = original_revision;
- svn_sort__array_insert(&new_segment, segments, 0);
+ svn_sort__array_insert(segments, &new_segment, 0);
                 }
             }
         }

Modified: subversion/trunk/subversion/libsvn_fs_fs/index.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/index.c?rev=1554619&r1=1554618&r2=1554619&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/index.c (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/index.c Wed Jan 1 13:58:10 2014
@@ -2326,7 +2326,7 @@ get_p2l_entry_from_cached_page(const voi
                                      (const void *const *)&page->elts);
 
   /* search of the offset we want */
- idx = svn_sort__bsearch_lower_bound(&offset, entries,
+ idx = svn_sort__bsearch_lower_bound(entries, &offset,
       (int (*)(const void *, const void *))compare_p2l_entry_offsets);
 
   /* return it, if it is a perfect match */
@@ -2393,7 +2393,7 @@ svn_fs_fs__p2l_entry_lookup(svn_fs_fs__p
       SVN_ERR(p2l_index_lookup(&entries, rev_file, fs, revision, offset, pool));
 
       /* Find the entry that we want. */
- idx = svn_sort__bsearch_lower_bound(&offset, entries,
+ idx = svn_sort__bsearch_lower_bound(entries, &offset,
           (int (*)(const void *, const void *))compare_p2l_entry_offsets);
 
       /* return it, if it is a perfect match */

Modified: subversion/trunk/subversion/libsvn_fs_fs/pack.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/pack.c?rev=1554619&r1=1554618&r2=1554619&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/pack.c (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/pack.c Wed Jan 1 13:58:10 2014
@@ -924,7 +924,7 @@ static int
 find_first_reference(pack_context_t *context,
                      svn_fs_fs__p2l_entry_t *item)
 {
- return svn_sort__bsearch_lower_bound(&item->item, context->references,
+ return svn_sort__bsearch_lower_bound(context->references, &item->item,
                 (int (*)(const void *, const void *))compare_ref_to_item);
 }
 

Modified: subversion/trunk/subversion/libsvn_fs_fs/transaction.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/transaction.c?rev=1554619&r1=1554618&r2=1554619&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/transaction.c (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/transaction.c Wed Jan 1 13:58:10 2014
@@ -3326,7 +3326,7 @@ verify_moves(svn_fs_t *fs,
     {
       const char *deleted_path = APR_ARRAY_IDX(deletions, i, const char*);
       int closest_move_idx
- = svn_sort__bsearch_lower_bound(deleted_path, moves,
+ = svn_sort__bsearch_lower_bound(moves, deleted_path,
                                         svn_sort_compare_paths);
 
       if (closest_move_idx < moves->nelts)
@@ -3382,7 +3382,7 @@ verify_moves(svn_fs_t *fs,
          (or any of its parents) */
 
       int closest_deletion_idx
- = svn_sort__bsearch_lower_bound(change->copyfrom_path, deletions,
+ = svn_sort__bsearch_lower_bound(deletions, change->copyfrom_path,
                                         svn_sort_compare_paths);
       if (closest_deletion_idx < deletions->nelts)
         {

Modified: subversion/trunk/subversion/libsvn_fs_x/index.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_x/index.c?rev=1554619&r1=1554618&r2=1554619&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_x/index.c (original)
+++ subversion/trunk/subversion/libsvn_fs_x/index.c Wed Jan 1 13:58:10 2014
@@ -2437,7 +2437,7 @@ get_p2l_entry_from_cached_page(const voi
                                      (const void *const *)&page->elts);
 
   /* search of the offset we want */
- idx = svn_sort__bsearch_lower_bound(&offset, entries,
+ idx = svn_sort__bsearch_lower_bound(entries, &offset,
       (int (*)(const void *, const void *))compare_p2l_entry_offsets);
 
   /* return it, if it is a perfect match */
@@ -2510,7 +2510,7 @@ p2l_entry_lookup(svn_fs_x__p2l_entry_t *
       SVN_ERR(p2l_index_lookup(&entries, stream, fs, revision, offset, pool));
 
       /* Find the entry that we want. */
- idx = svn_sort__bsearch_lower_bound(&offset, entries,
+ idx = svn_sort__bsearch_lower_bound(entries, &offset,
           (int (*)(const void *, const void *))compare_p2l_entry_offsets);
 
       /* return it, if it is a perfect match */

Modified: subversion/trunk/subversion/libsvn_fs_x/transaction.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_x/transaction.c?rev=1554619&r1=1554618&r2=1554619&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_x/transaction.c (original)
+++ subversion/trunk/subversion/libsvn_fs_x/transaction.c Wed Jan 1 13:58:10 2014
@@ -2957,7 +2957,7 @@ verify_moves(svn_fs_t *fs,
     {
       const char *deleted_path = APR_ARRAY_IDX(deletions, i, const char*);
       int closest_move_idx
- = svn_sort__bsearch_lower_bound(deleted_path, moves,
+ = svn_sort__bsearch_lower_bound(moves, deleted_path,
                                         svn_sort_compare_paths);
 
       if (closest_move_idx < moves->nelts)
@@ -3013,7 +3013,7 @@ verify_moves(svn_fs_t *fs,
          (or any of its parents) */
 
       int closest_deletion_idx
- = svn_sort__bsearch_lower_bound(change->copyfrom_path, deletions,
+ = svn_sort__bsearch_lower_bound(deletions, change->copyfrom_path,
                                         svn_sort_compare_paths);
       if (closest_deletion_idx < deletions->nelts)
         {

Modified: subversion/trunk/subversion/libsvn_ra/compat.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra/compat.c?rev=1554619&r1=1554618&r2=1554619&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra/compat.c (original)
+++ subversion/trunk/subversion/libsvn_ra/compat.c Wed Jan 1 13:58:10 2014
@@ -944,7 +944,7 @@ svn_ra__get_inherited_props_walk(svn_ra_
                                                          parent_url,
                                                          result_pool);
           new_iprop->prop_hash = final_hash;
- svn_sort__array_insert(&new_iprop, *inherited_props, 0);
+ svn_sort__array_insert(*inherited_props, &new_iprop, 0);
         }
     }
 

Modified: subversion/trunk/subversion/libsvn_ra_serf/inherited_props.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/inherited_props.c?rev=1554619&r1=1554618&r2=1554619&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/inherited_props.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/inherited_props.c Wed Jan 1 13:58:10 2014
@@ -364,7 +364,7 @@ get_iprops_via_more_requests(svn_ra_sess
       new_iprop = apr_palloc(result_pool, sizeof(*new_iprop));
       new_iprop->path_or_url = apr_pstrdup(result_pool, rq->relpath);
       new_iprop->prop_hash = svn_prop_hash_dup(node_props, result_pool);
- svn_sort__array_insert(&new_iprop, *iprops, 0);
+ svn_sort__array_insert(*iprops, &new_iprop, 0);
     }
 
   return SVN_NO_ERROR;

Modified: subversion/trunk/subversion/libsvn_repos/fs-wrap.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_repos/fs-wrap.c?rev=1554619&r1=1554618&r2=1554619&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_repos/fs-wrap.c (original)
+++ subversion/trunk/subversion/libsvn_repos/fs-wrap.c Wed Jan 1 13:58:10 2014
@@ -851,7 +851,7 @@ svn_repos_fs_get_inherited_props(apr_arr
                 apr_pstrdup(result_pool, parent_path + 1);
               i_props->prop_hash = parent_properties;
               /* Build the output array in depth-first order. */
- svn_sort__array_insert(&i_props, inherited_props, 0);
+ svn_sort__array_insert(inherited_props, &i_props, 0);
             }
         }
     }

Modified: subversion/trunk/subversion/libsvn_subr/mergeinfo.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/mergeinfo.c?rev=1554619&r1=1554618&r2=1554619&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/mergeinfo.c (original)
+++ subversion/trunk/subversion/libsvn_subr/mergeinfo.c Wed Jan 1 13:58:10 2014
@@ -878,7 +878,7 @@ adjust_remaining_ranges(svn_rangelist_t
               new_modified_range->inheritable = FALSE;
               modified_range->end = next_range->start;
               (*range_index)+=2;
- svn_sort__array_insert(&new_modified_range, rangelist,
+ svn_sort__array_insert(rangelist, &new_modified_range,
                                      *range_index);
               /* Recurse with the new range. */
               adjust_remaining_ranges(rangelist, range_index, result_pool);
@@ -1019,7 +1019,7 @@ svn_rangelist_merge2(svn_rangelist_t *ra
                         svn_merge_range_dup(range, result_pool);
                       range_copy->end = change->start;
                       range->start = change->start;
- svn_sort__array_insert(&range_copy, rangelist, i++);
+ svn_sort__array_insert(rangelist, &range_copy, i++);
                     }
                   else
                     {
@@ -1041,7 +1041,7 @@ svn_rangelist_merge2(svn_rangelist_t *ra
                  into RANGELIST. */
               svn_merge_range_t *change_copy =
                 svn_merge_range_dup(change, result_pool);
- svn_sort__array_insert(&change_copy, rangelist, i++);
+ svn_sort__array_insert(rangelist, &change_copy, i++);
               j++;
             }
           else if (change->end == range->start)
@@ -1060,7 +1060,7 @@ svn_rangelist_merge2(svn_rangelist_t *ra
                      a copy of CHANGE into RANGELIST. */
                   svn_merge_range_t *change_copy =
                     svn_merge_range_dup(change, result_pool);
- svn_sort__array_insert(&change_copy, rangelist, i);
+ svn_sort__array_insert(rangelist, &change_copy, i);
                   j++;
                 }
             }
@@ -1092,7 +1092,7 @@ svn_rangelist_merge2(svn_rangelist_t *ra
                         svn_merge_range_dup(change, result_pool);
                       change_copy->end = range->start;
                       change->start = range->start;
- svn_sort__array_insert(&change_copy, rangelist, i++);
+ svn_sort__array_insert(rangelist, &change_copy, i++);
                     }
                   else
                     {
@@ -1135,7 +1135,7 @@ svn_rangelist_merge2(svn_rangelist_t *ra
                           range->start = change->start;
                           range->end = change->end;
                           range->inheritable = TRUE;
- svn_sort__array_insert(&range_copy, rangelist, ++i);
+ svn_sort__array_insert(rangelist, &range_copy, ++i);
                           j++;
                         }
                     }
@@ -1153,7 +1153,7 @@ svn_rangelist_merge2(svn_rangelist_t *ra
                       range_copy->end = change->end;
                       range_copy->inheritable = TRUE;
                       range->start = change->end;
- svn_sort__array_insert(&range_copy, rangelist, i++);
+ svn_sort__array_insert(rangelist, &range_copy, i++);
                       j++;
                     }
                 }
@@ -1168,7 +1168,7 @@ svn_rangelist_merge2(svn_rangelist_t *ra
         APR_ARRAY_IDX(changes, j, svn_merge_range_t *);
       svn_merge_range_t *change_copy = svn_merge_range_dup(change,
                                                            result_pool);
- svn_sort__array_insert(&change_copy, rangelist, rangelist->nelts);
+ svn_sort__array_insert(rangelist, &change_copy, rangelist->nelts);
     }
 
   return SVN_NO_ERROR;

Modified: subversion/trunk/subversion/libsvn_subr/sorts.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/sorts.c?rev=1554619&r1=1554618&r2=1554619&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/sorts.c (original)
+++ subversion/trunk/subversion/libsvn_subr/sorts.c Wed Jan 1 13:58:10 2014
@@ -215,8 +215,8 @@ bsearch_lower_bound(const void *key,
 }
 
 int
-svn_sort__bsearch_lower_bound(const void *key,
- const apr_array_header_t *array,
+svn_sort__bsearch_lower_bound(const apr_array_header_t *array,
+ const void *key,
                               int (*compare_func)(const void *, const void *))
 {
   return bsearch_lower_bound(key,
@@ -225,8 +225,8 @@ svn_sort__bsearch_lower_bound(const void
 }
 
 void
-svn_sort__array_insert(const void *new_element,
- apr_array_header_t *array,
+svn_sort__array_insert(apr_array_header_t *array,
+ const void *new_element,
                        int insert_index)
 {
   int elements_to_move;

Modified: subversion/trunk/subversion/libsvn_wc/wc_db.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.c?rev=1554619&r1=1554618&r2=1554619&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.c Wed Jan 1 13:58:10 2014
@@ -10282,7 +10282,7 @@ db_read_inherited_props(apr_array_header
 
                   iprop_elt->prop_hash = node_props;
                   /* Build the output array in depth-first order. */
- svn_sort__array_insert(&iprop_elt, iprops, 0);
+ svn_sort__array_insert(iprops, &iprop_elt, 0);
                 }
             }
         }
@@ -10318,7 +10318,7 @@ db_read_inherited_props(apr_array_header
 
           /* If we didn't filter everything then keep this iprop. */
           if (apr_hash_count(cached_iprop->prop_hash))
- svn_sort__array_insert(&cached_iprop, iprops, 0);
+ svn_sort__array_insert(iprops, &cached_iprop, 0);
         }
     }
 

Modified: subversion/trunk/tools/server-side/fsfs-stats.c
URL: http://svn.apache.org/viewvc/subversion/trunk/tools/server-side/fsfs-stats.c?rev=1554619&r1=1554618&r2=1554619&view=diff
==============================================================================
--- subversion/trunk/tools/server-side/fsfs-stats.c (original)
+++ subversion/trunk/tools/server-side/fsfs-stats.c Wed Jan 1 13:58:10 2014
@@ -697,8 +697,8 @@ find_representation(int *idx,
   assert(revision == info->revision);
 
   /* look for the representation */
- *idx = svn_sort__bsearch_lower_bound(&offset,
- info->representations,
+ *idx = svn_sort__bsearch_lower_bound(info->representations,
+ &offset,
                                        compare_representation_offsets);
   if (*idx < info->representations->nelts)
     {
@@ -831,7 +831,7 @@ parse_representation(rep_stats_t **repre
           result->is_plain = is_plain;
         }
 
- svn_sort__array_insert(&result, revision_info->representations, idx);
+ svn_sort__array_insert(revision_info->representations, &result, idx);
     }
 
   *representation = result;
Received on 2014-01-02 16:49:27 CET

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

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.