At 09:40 PM 06/09/2006 +0100, Philip Martin wrote:
>"Jonathan Gilbert" <o2w9gs702@sneakemail.com> writes:
>> static svn_boolean_t
>> combine_ranges(svn_merge_range_t **output, svn_merge_range_t *in1,
>> svn_merge_range_t *in2)
>> {
>> if (range_contains_revision(in1, in2->start)
>> || range_contains_revision(in2, in1->start)
>> || ranges_are_adjacent(in1, in2))
>> {
[snip]
>
>I haven't been following the merge tracking stuff, but detecting
>overlapping ranges is notorious for being both tricky and simple: it's
>tricky to get the algorithm right, but the right algorithm is simple.
>
>static svn_boolean_t
>combine_ranges(svn_merge_range_t **output,
> svn_merge_range_t *in1,
> svn_merge_range_t *in2)
>{
> if (in1->start <= in2->end + 1 && in2->start <= in1->end + 1)
> {
[snip]
Wow, that _is_ concise :-) I actually had a feeling something like that
would be possible when I was composing my message, but it didn't spring
into my head at the time. In any case, though my example is more verbose
and adds two extra functions, I think it's more maintainable, and it is
certainly more self-documenting.
The added functions could also probably be used elsewhere to improve the
readability/maintainability of other code that needs similar operations.
Certainly, there's no reason to overoptimize something that is only
O(number of revisions/ranges of revisions to be merged). :-)
Jonathan Gilbert
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Thu Sep 7 00:19:36 2006