subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhuij...@apache.org
Subject svn commit: r1802471 - /subversion/trunk/subversion/libsvn_subr/mergeinfo.c
Date Thu, 20 Jul 2017 10:51:26 GMT
Author: rhuijben
Date: Thu Jul 20 10:51:25 2017
New Revision: 1802471

URL: http://svn.apache.org/viewvc?rev=1802471&view=rev
Log:
Following up on r1802470, handle the no overlap cases in one place.

* subversion/libsvn_subr/mergeinfo.c
  (svn_rangelist_merge2): Collapse all the no overlap cases in the loop
    handling.

Modified:
    subversion/trunk/subversion/libsvn_subr/mergeinfo.c

Modified: subversion/trunk/subversion/libsvn_subr/mergeinfo.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/mergeinfo.c?rev=1802471&r1=1802470&r2=1802471&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/mergeinfo.c (original)
+++ subversion/trunk/subversion/libsvn_subr/mergeinfo.c Thu Jul 20 10:51:25 2017
@@ -977,11 +977,26 @@ svn_rangelist_merge2(svn_rangelist_t *ra
         APR_ARRAY_IDX(changes, j, svn_merge_range_t *);
       int res;
 
-      /* ### TODO: Remove as part of refactoring */
-      if (i >= rangelist->nelts)
-        break;
+      range = (i < rangelist->nelts)
+              ? APR_ARRAY_IDX(rangelist, i, svn_merge_range_t *)
+              : NULL;
+
+      if (!range || change->end < range->start)
+        {
+          /* No overlap, nor adjoin, copy change to result range */
+          svn_merge_range_t *chg_copy = svn_merge_range_dup(change,
+                                                            result_pool);
+          svn_sort__array_insert(rangelist, &chg_copy, i++);
+          continue;
+        }
+      else if (change->start > range->end)
+        {
+          /* No overlap, nor adjoin. Check next range item against change */
+          i++;
+          j--;
+          continue;
+        }
 
-      range = APR_ARRAY_IDX(rangelist, i, svn_merge_range_t *);
       res = svn_sort_compare_ranges(&range, &change);
 
       if (res == 0)
@@ -996,15 +1011,7 @@ svn_rangelist_merge2(svn_rangelist_t *ra
         }
       else if (res < 0) /* CHANGE is younger than RANGE */
         {
-          if (range->end < change->start)
-            {
-              /* RANGE is older than CHANGE and the two do not
-                 adjoin or overlap */
-              i++;
-              j--;
-              continue;
-            }
-          else if (range->end == change->start)
+          if (range->end == change->start)
             {
               /* RANGE and CHANGE adjoin */
               if (range->inheritable == change->inheritable)
@@ -1073,17 +1080,7 @@ svn_rangelist_merge2(svn_rangelist_t *ra
         }
       else /* res > 0, CHANGE is older than RANGE */
         {
-          if (change->end < range->start)
-            {
-              /* CHANGE is older than RANGE and the two do not
-                 adjoin or overlap, so insert a copy of CHANGE
-                 into RANGELIST. */
-              svn_merge_range_t *change_copy =
-                svn_merge_range_dup(change, result_pool);
-              svn_sort__array_insert(rangelist, &change_copy, i++);
-              continue;
-            }
-          else if (change->end == range->start)
+          if (change->end == range->start)
             {
               /* RANGE and CHANGE adjoin */
               if (range->inheritable == change->inheritable)
@@ -1205,16 +1202,6 @@ svn_rangelist_merge2(svn_rangelist_t *ra
       SVN_ERR_MALFUNCTION(); /* Unreachable */
     }
 
-  /* Copy any remaining elements in CHANGES into RANGELIST. */
-  for (; j < (changes)->nelts; j++)
-    {
-      svn_merge_range_t *change =
-        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(rangelist, &change_copy, rangelist->nelts);
-    }
-
 #ifdef SVN_DEBUG
   SVN_ERR_ASSERT(svn_rangelist__is_canonical(rangelist));
 #endif



Mime
View raw message