monotone-commits-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Monotone-commits-diffs] net.venge.monotone: 046dc30d4daa08782a3d6b6947


From: code
Subject: [Monotone-commits-diffs] net.venge.monotone: 046dc30d4daa08782a3d6b6947db6f9dc1387614
Date: Fri, 18 Feb 2011 20:54:20 +0100 (CET)

revision:            046dc30d4daa08782a3d6b6947db6f9dc1387614
date:                2011-02-10T03:41:57
author:              Timothy Brownawell  <address@hidden>
branch:              net.venge.monotone
changelog:
Rename a couple variables in lcs.cc, and make p_lim internal to lcs.cc.

manifest:
format_version "1"

new_manifest [c8785df2b51fae330f708289925da16e591f6a36]

old_revision [a54ec428f3093cc06fc51860dff5ca0e4949d180]

patch "src/annotate.cc"
 from [78623ee33981036087734face30811d6143aa8fc]
   to [28ad5569c22bb905380ce6abbb73f6d6ad5c629b]

patch "src/diff_output.cc"
 from [1e537406208bd9ff6afd2a728389d1c4f34acaf2]
   to [8df7c0bec2e64275f6c8e8b6ccb035c8fd0f684f]

patch "src/lcs.cc"
 from [f910a6d0679cc8ca110c9ee3d69e864ea5d63343]
   to [3b38a559cbf6ee3c32e8b5f7515afc8a092ca016]

patch "src/lcs.hh"
 from [11373d3b6fa6c8deba61b60e657d3b084d53400c]
   to [e7d621a7331994bbb614168313419d61e306bbd3]

patch "src/merge_3way.cc"
 from [569fce0fc1a72f06b9a7266b69ea4b3e12e70432]
   to [f415f5ddbcfafbc8c822b2e3a848f48f968287af]
============================================================
--- src/diff_output.cc	1e537406208bd9ff6afd2a728389d1c4f34acaf2
+++ src/diff_output.cc	8df7c0bec2e64275f6c8e8b6ccb035c8fd0f684f
@@ -507,7 +507,6 @@ make_diff(string const & filename1,
   lcs.reserve(min(lines1.size(),lines2.size()));
   longest_common_subsequence(left_interned.begin(), left_interned.end(),
                              right_interned.begin(), right_interned.end(),
-                             min(lines1.size(), lines2.size()),
                              back_inserter(lcs));
 
   // The existence of various hacky diff parsers in the world somewhat
============================================================
--- src/lcs.hh	11373d3b6fa6c8deba61b60e657d3b084d53400c
+++ src/lcs.hh	e7d621a7331994bbb614168313419d61e306bbd3
@@ -19,7 +19,6 @@ longest_common_subsequence(std::vector<l
                            std::vector<long, QA(long)>::const_iterator end_a,
                            std::vector<long, QA(long)>::const_iterator begin_b,
                            std::vector<long, QA(long)>::const_iterator end_b,
-                           long p_lim,
                            std::back_insert_iterator< std::vector<long, QA(long)> > lcs);
 
 void
@@ -27,7 +26,6 @@ edit_script(std::vector<long, QA(long)>:
             std::vector<long, QA(long)>::const_iterator end_a,
             std::vector<long, QA(long)>::const_iterator begin_b,
             std::vector<long, QA(long)>::const_iterator end_b,
-            long p_lim,
             std::vector<long, QA(long)> & edits_out);
 
 #endif // __LCS_HH__
============================================================
--- src/lcs.cc	f910a6d0679cc8ca110c9ee3d69e864ea5d63343
+++ src/lcs.cc	3b38a559cbf6ee3c32e8b5f7515afc8a092ca016
@@ -459,37 +459,34 @@ struct jaffer_edit_calculator
       }
   }
 
-  static void diff_to_edits(subarray<A> const & a, long m,
-                            subarray<B> const & b, long n,
-                            vector<long, QA(long)> & edits,
-                            long p_lim)
+  static void diff_to_edits(subarray<A> const & a, long len_a,
+                            subarray<B> const & b, long len_b,
+                            vector<long, QA(long)> & edits)
   {
-    I(m <= n);
-    cost_vec costs(m+n); // scratch array, ignored
-    long edit_distance = compare(costs, a, m, b, n, p_lim, false);
+    I(len_a <= len_b);
+    cost_vec costs(len_a + len_b); // scratch array, ignored
+    long edit_distance = compare(costs, a, len_a, b, len_b, min(len_a, len_b), false);
 
     edits.clear();
     edits.resize(edit_distance, 0);
-    long cost = diff_to_et(a, 0, m,
-                           b, 0, n,
-                           edits, 0, 1, (edit_distance - (n-m)) / 2);
+    long cost = diff_to_et(a, 0, len_a,
+                           b, 0, len_b,
+                           edits, 0, 1, (edit_distance - (len_b - len_a)) / 2);
     I(cost == edit_distance);
   }
 
   static void edits_to_lcs (vector<long, QA(long)> const & edits,
-                            subarray<A> const a, long m, long n,
+                            subarray<A> const a, long len_a, long len_b,
                             LCS output)
   {
     long edx = 0, sdx = 0, adx = 0;
     typedef typename iterator_traits<A>::value_type vt;
-    vector<vt, QA(vt)> lcs(((m + n) - edits.size()) / 2);
-    while (true)
+    vector<vt, QA(vt)> lcs(((len_a + len_b) - edits.size()) / 2);
+    while (adx < len_a)
       {
         long edit = (edx < static_cast<long>(edits.size())) ? edits[edx] : 0;
 
-        if (adx >= m)
-          break;
-        else if (edit > 0)
+        if (edit > 0)
           { ++edx; }
         else if (edit == 0)
           { lcs[sdx++] = a[adx++]; }
@@ -509,7 +506,6 @@ void _edit_script(A begin_a, A end_a,
           typename LCS>
 void _edit_script(A begin_a, A end_a,
                   B begin_b, B end_b,
-                  long p_lim,
                   vector<long, QA(long)> & edits_out,
                   LCS ignored_out)
 {
@@ -523,14 +519,14 @@ void _edit_script(A begin_a, A end_a,
 
   if (len_b < len_a)
     {
-      calc_t::diff_to_edits (b, len_b, a, len_a, edits, p_lim);
+      calc_t::diff_to_edits (b, len_b, a, len_a, edits);
       calc_t::order_edits (edits, -1, ordered);
       for (size_t i = 0; i < ordered.size(); ++i)
         ordered[i] *= -1;
     }
   else
     {
-      calc_t::diff_to_edits (a, len_a, b, len_b, edits, p_lim);
+      calc_t::diff_to_edits (a, len_a, b, len_b, edits);
       calc_t::order_edits (edits, 1, ordered);
     }
 
@@ -545,7 +541,6 @@ void _longest_common_subsequence(A begin
           typename LCS>
 void _longest_common_subsequence(A begin_a, A end_a,
                                  B begin_b, B end_b,
-                                 long p_lim,
                                  LCS out)
 {
   typedef jaffer_edit_calculator<A,B,LCS> calc_t;
@@ -558,13 +553,13 @@ void _longest_common_subsequence(A begin
 
   if (len_b < len_a)
     {
-      calc_t::diff_to_edits(b, len_b, a, len_a, edits, p_lim);
+      calc_t::diff_to_edits(b, len_b, a, len_a, edits);
       calc_t::order_edits(edits, -1, ordered);
       calc_t::edits_to_lcs(ordered, b, len_b, len_a, out);
     }
   else
     {
-      calc_t::diff_to_edits(a, len_a, b, len_b, edits, p_lim);
+      calc_t::diff_to_edits(a, len_a, b, len_b, edits);
       calc_t::order_edits(edits, 1, ordered);
       calc_t::edits_to_lcs(ordered, a, len_a, len_b, out);
     }
@@ -576,12 +571,11 @@ longest_common_subsequence(vector<long, 
                            vector<long, QA(long)>::const_iterator end_a,
                            vector<long, QA(long)>::const_iterator begin_b,
                            vector<long, QA(long)>::const_iterator end_b,
-                           long p_lim,
                            back_insert_iterator< vector<long, QA(long)> > lcs)
 {
   _longest_common_subsequence(begin_a, end_a,
                               begin_b, end_b,
-                              p_lim, lcs);
+                              lcs);
 }
 
 void
@@ -589,13 +583,12 @@ edit_script(vector<long, QA(long)>::cons
             vector<long, QA(long)>::const_iterator end_a,
             vector<long, QA(long)>::const_iterator begin_b,
             vector<long, QA(long)>::const_iterator end_b,
-            long p_lim,
             vector<long, QA(long)> & edits_out)
 {
   vector<long, QA(long)> lcs;
   _edit_script(begin_a, end_a,
                begin_b, end_b,
-               p_lim, edits_out,
+               edits_out,
                back_inserter(lcs));
 }
 
============================================================
--- src/annotate.cc	78623ee33981036087734face30811d6143aa8fc
+++ src/annotate.cc	28ad5569c22bb905380ce6abbb73f6d6ad5c629b
@@ -568,8 +568,6 @@ annotate_lineage_mapping::build_parent_l
                              file_interned.end(),
                              parent_lineage->file_interned.begin(),
                              parent_lineage->file_interned.end(),
-                             min(file_interned.size(),
-                                 parent_lineage->file_interned.size()),
                              back_inserter(lcs));
 
   if (verbose)
============================================================
--- src/merge_3way.cc	569fce0fc1a72f06b9a7266b69ea4b3e12e70432
+++ src/merge_3way.cc	f415f5ddbcfafbc8c822b2e3a848f48f968287af
@@ -385,7 +385,6 @@ void merge_via_edit_scripts(vector<strin
 
   edit_script(anc_interned.begin(), anc_interned.end(),
               left_interned.begin(), left_interned.end(),
-              min(ancestor.size(), left.size()),
               left_edits);
 
   L(FL("calculating right edit script on %d -> %d lines")
@@ -393,7 +392,6 @@ void merge_via_edit_scripts(vector<strin
 
   edit_script(anc_interned.begin(), anc_interned.end(),
               right_interned.begin(), right_interned.end(),
-              min(ancestor.size(), right.size()),
               right_edits);
 
   L(FL("calculating left extents on %d edits") % left_edits.size());

reply via email to

[Prev in Thread] Current Thread [Next in Thread]