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

[PATCH] Simplify mergeinfo search and insertion functions

From: Julian Foad <julianfoad_at_btopenworld.com>
Date: Tue, 23 Sep 2008 20:47:34 +0100

Paul and others,

I noticed that some of the code in libsvn_client/merge.c seems to be
implementing "search in a sorted array" and "insert an element into an
array" in its own way. I would like to see those bits of algorithm moved
out to somewhere generic so they don't clutter the mergeinfo-specific
code.

Please review the attached patch. Here is the clean version of the log
message[*]:

[[[
Factor out some generic array manipulation logic from the code that handles
CHILDREN_WITH_MERGEINFO arrays.

Create functions for searching and inserting in a generic sorted APR array.
Replace the search function find_child_or_parent() and the insertion
function insert_child_to_merge() with functions that do the same jobs using
the generic helpers. Stop requiring the caller to remember the index where
the next item should be inserted, as that is error-prone.

* subversion/libsvn_client/merge.c
  (compare_merge_path_t_as_paths): Move this function to an earlier point in
    the source file. Add a doc string.
  (get_child_with_mergeinfo): New function.
  (find_child_or_parent, find_child_with_mergeinfo): Delete.
  (svn_client__merge_path_dup): New function.
  (insert_child_to_merge): Re-write.
  (insert_parent_and_sibs_of_sw_absent_del_entry, get_mergeinfo_paths,
   process_children_with_new_mergeinfo): Adjust for the above changes,
    eliminating the indexes.

* subversion/include/svn_sorts.h
  (svn_sort__bsearch_lower_bound, svn_sort__array_insert): New functions.

* subversion/libsvn_subr/sorts.c
  (bsearch_lower_bound): New function.
  (svn_sort__bsearch_lower_bound, svn_sort__array_insert): New functions.
]]]

[1] The attached version of the patch keeps the old code in as well, and
checks the results of the new code against the old, to give me
confidence in it. It passes the basic "make check".

svn_sorts.c isn't necessarily the right place for the array manipulation
functions, but searching and inserting do go hand-in-hand with sorting.
svn_sorts.h isn't necessarily the right header for them if defined as
private functions, but we already have a private "svn_sort__hash()"
there. We can move them to somewhere better if we like.

- Julian

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe_at_subversion.tigris.org
For additional commands, e-mail: dev-help_at_subversion.tigris.org

Received on 2008-09-23 21:47:56 CEST

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