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

[PATCH v3 4/8] recs_match(): take two xrecord_t pointers as arguments

From
Michael Haggerty <mhagger@alum.mit.edu>
Date
Sep 5, 2016, 09:44 UTC
Message-ID
<1f7f17cc1b2434ab5dfc4fea95a09597e61a4886.1473068229.git.mhagger@alum.mit.edu>
In-Reply-To
<cover.1473068229.git.mhagger@alum.mit.edu>

There is no reason for it to take an array and two indexes as argument, as it only accesses two elements of the array.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
---
 xdiff/xdiffi.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/xdiff/xdiffi.c b/xdiff/xdiffi.c
index ed2df64..8a5832a 100644
--- a/xdiff/xdiffi.c
+++ b/xdiff/xdiffi.c
@@ -405,11 +405,11 @@ static int is_blank_line(xrecord_t *rec, long flags)
 	return xdl_blankline(rec->ptr, rec->size, flags);
 }
 
-static int recs_match(xrecord_t **recs, long ixs, long ix, long flags)
+static int recs_match(xrecord_t *rec1, xrecord_t *rec2, long flags)
 {
-	return (recs[ixs]->ha == recs[ix]->ha &&
-		xdl_recmatch(recs[ixs]->ptr, recs[ixs]->size,
-			     recs[ix]->ptr, recs[ix]->size,
+	return (rec1->ha == rec2->ha &&
+		xdl_recmatch(rec1->ptr, rec1->size,
+			     rec2->ptr, rec2->size,
 			     flags));
 }
 
@@ -457,7 +457,7 @@ int xdl_change_compact(xdfile_t *xdf, xdfile_t *xdfo, long flags) {
 			 * the last line of the current change group, shift backward
 			 * the group.
 			 */
-			while (ixs > 0 && recs_match(recs, ixs - 1, ix - 1, flags)) {
+			while (ixs > 0 && recs_match(recs[ixs - 1], recs[ix - 1], flags)) {
 				rchg[--ixs] = 1;
 				rchg[--ix] = 0;
 
@@ -484,7 +484,7 @@ int xdl_change_compact(xdfile_t *xdf, xdfile_t *xdfo, long flags) {
 			 * the line next of the current change group, shift forward
 			 * the group.
 			 */
-			while (ix < nrec && recs_match(recs, ixs, ix, flags)) {
+			while (ix < nrec && recs_match(recs[ixs], recs[ix], flags)) {
 				blank_lines += is_blank_line(recs[ix], flags);
 
 				rchg[ixs++] = 0;
@@ -525,7 +525,7 @@ int xdl_change_compact(xdfile_t *xdf, xdfile_t *xdfo, long flags) {
 			 */
 			while (ixs > 0 &&
 			       !is_blank_line(recs[ix - 1], flags) &&
-			       recs_match(recs, ixs - 1, ix - 1, flags)) {
+			       recs_match(recs[ixs - 1], recs[ix - 1], flags)) {
 				rchg[--ixs] = 1;
 				rchg[--ix] = 0;
 				while (rchgo[--ixo]);
-- 
2.9.3
Previous: Michael HaggertyNext: Junio C Hamano
Message 9 of 16 in “Better heuristics make prettier diffs”
  1. 0/8 Better heuristics make prettier diffsMichael Haggerty, Sep 5, 2016
  2. 1/8 xdl_change_compact(): fix compaction heuristic to adjust ixoMichael Haggerty, Sep 5, 2016
  3. 7/8 parse-options: add parse_opt_unknown_cb()Michael Haggerty, Sep 5, 2016
  4. 3/8 is_blank_line(): take a single xrecord_t as argumentMichael Haggerty, Sep 5, 2016
  5. 2/8 xdl_change_compact(): only use heuristic if group can't be matchedMichael Haggerty, Sep 5, 2016
  6. 5/8 xdl_change_compact(): introduce the concept of a change groupMichael Haggerty, Sep 5, 2016
  7. 8/8 blame: honor the diff heuristic options and configMichael Haggerty, Sep 5, 2016
  8. 6/8 diff: improve positioning of add/delete blocks in diffsMichael Haggerty, Sep 5, 2016
  9. 4/8 recs_match(): take two xrecord_t pointers as argumentsMichael Haggerty, Sep 5, 2016
  10. Junio C HamanoSep 7, 2016
  11. Jacob KellerSep 7, 2016
  12. Junio C HamanoSep 7, 2016
  13. Michael HaggertySep 19, 2016
  14. Junio C HamanoSep 19, 2016
  15. Junio C HamanoSep 19, 2016
  16. Michael HaggertySep 20, 2016

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.