git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/3] xdiff/xhistogram: pass arguments directly to fall_back_to_classic_diff

From
Stefan Beller <sbeller@google.com>
Date
Jul 19, 2018, 18:56 UTC
Message-ID
<20180719185620.124768-2-sbeller@google.com>
In-Reply-To
<20180719185620.124768-1-sbeller@google.com>

By passing the 'xpp' and 'env' argument directly to the function 'fall_back_to_classic_diff', we eliminate an occurrence of the 'index' in histogram_diff, which will prove useful in a bit.

While at it, move it up in the file. This will make the diff of one of the next patches more legible.

Signed-off-by: Stefan Beller <sbeller@google.com>
---
 xdiff/xhistogram.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/xdiff/xhistogram.c b/xdiff/xhistogram.c
index 73210cb6f3f..6e20f75fe85 100644
--- a/xdiff/xhistogram.c
+++ b/xdiff/xhistogram.c
@@ -233,6 +233,16 @@ static int try_lcs(struct histindex *index, struct region *lcs, int b_ptr,
 	return b_next;
 }
 
+static int fall_back_to_classic_diff(xpparam_t const *xpp, xdfenv_t *env,
+		int line1, int count1, int line2, int count2)
+{
+	xpparam_t xpparam;
+	xpparam.flags = xpp->flags & ~XDF_DIFF_ALGORITHM_MASK;
+
+	return xdl_fall_back_diff(env, &xpparam,
+				  line1, count1, line2, count2);
+}
+
 static int find_lcs(struct histindex *index, struct region *lcs,
 	int line1, int count1, int line2, int count2) {
 	int b_ptr;
@@ -248,16 +258,6 @@ static int find_lcs(struct histindex *index, struct region *lcs,
 	return index->has_common && index->max_chain_length < index->cnt;
 }
 
-static int fall_back_to_classic_diff(struct histindex *index,
-		int line1, int count1, int line2, int count2)
-{
-	xpparam_t xpp;
-	xpp.flags = index->xpp->flags & ~XDF_DIFF_ALGORITHM_MASK;
-
-	return xdl_fall_back_diff(index->env, &xpp,
-				  line1, count1, line2, count2);
-}
-
 static int histogram_diff(xpparam_t const *xpp, xdfenv_t *env,
 	int line1, int count1, int line2, int count2)
 {
@@ -320,7 +320,7 @@ static int histogram_diff(xpparam_t const *xpp, xdfenv_t *env,
 
 	memset(&lcs, 0, sizeof(lcs));
 	if (find_lcs(&index, &lcs, line1, count1, line2, count2))
-		result = fall_back_to_classic_diff(&index, line1, count1, line2, count2);
+		result = fall_back_to_classic_diff(xpp, env, line1, count1, line2, count2);
 	else {
 		if (lcs.begin1 == 0 && lcs.begin2 == 0) {
 			while (count1--)
-- 
2.18.0.233.g985f88cf7e-goog
Previous: Stefan BellerNext: Stefan Beller
Message 2 of 5 in “histogram diff: Fix memory ballooning in corner case”
  1. 0/3 histogram diff: Fix memory ballooning in corner caseStefan Beller, Jul 19, 2018
  2. 1/3 xdiff/xhistogram: pass arguments directly to fall_back_to_classic_diffStefan Beller, Jul 19, 2018
  3. 2/3 xdiff/xhistogram: factor out memory cleanup into free_index()Stefan Beller, Jul 19, 2018
  4. 3/3 xdiff/xhistogram: move index allocation into find_lcsStefan Beller, Jul 19, 2018
  5. xdiff/histogram: remove tail recursionStefan Beller, Jul 19, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.