All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Carlo Marcelo Arenas Belón" <carenas@gmail.com>
To: git@vger.kernel.org
Cc: sandals@crustytoothpaste.net,
	"Carlo Marcelo Arenas Belón" <carenas@gmail.com>
Subject: [PATCH 3/3] xdiff: use compat's MIN instead
Date: Sun, 21 Oct 2018 22:36:05 -0700	[thread overview]
Message-ID: <20181022053605.81048-4-carenas@gmail.com> (raw)
In-Reply-To: <20181022053605.81048-1-carenas@gmail.com>

Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
---
 xdiff/xdiffi.c     | 2 +-
 xdiff/xemit.c      | 6 +++---
 xdiff/xhistogram.c | 6 +++---
 xdiff/xmacros.h    | 4 +---
 xdiff/xprepare.c   | 2 +-
 5 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/xdiff/xdiffi.c b/xdiff/xdiffi.c
index 1f1f4a3c78..0754dc17ed 100644
--- a/xdiff/xdiffi.c
+++ b/xdiff/xdiffi.c
@@ -204,7 +204,7 @@ static long xdl_split(unsigned long const *ha1, long off1, long lim1,
 
 			fbest = fbest1 = -1;
 			for (d = fmax; d >= fmin; d -= 2) {
-				i1 = XDL_MIN(kvdf[d], lim1);
+				i1 = MIN(kvdf[d], lim1);
 				i2 = i1 - d;
 				if (lim2 < i2)
 					i1 = lim2 + d, i2 = lim2;
diff --git a/xdiff/xemit.c b/xdiff/xemit.c
index 7778dc2b19..43d455b404 100644
--- a/xdiff/xemit.c
+++ b/xdiff/xemit.c
@@ -217,8 +217,8 @@ int xdl_emit_diff(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb,
 
  post_context_calculation:
 		lctx = xecfg->ctxlen;
-		lctx = XDL_MIN(lctx, xe->xdf1.nrec - (xche->i1 + xche->chg1));
-		lctx = XDL_MIN(lctx, xe->xdf2.nrec - (xche->i2 + xche->chg2));
+		lctx = MIN(lctx, xe->xdf1.nrec - (xche->i1 + xche->chg1));
+		lctx = MIN(lctx, xe->xdf2.nrec - (xche->i2 + xche->chg2));
 
 		e1 = xche->i1 + xche->chg1 + lctx;
 		e2 = xche->i2 + xche->chg2 + lctx;
@@ -242,7 +242,7 @@ int xdl_emit_diff(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb,
 			 * its new end.
 			 */
 			if (xche->next) {
-				long l = XDL_MIN(xche->next->i1,
+				long l = MIN(xche->next->i1,
 						 xe->xdf1.nrec - 1);
 				if (l - xecfg->ctxlen <= e1 ||
 				    get_func_line(xe, xecfg, NULL, l, e1) < 0) {
diff --git a/xdiff/xhistogram.c b/xdiff/xhistogram.c
index ec85f5992b..562cab6d14 100644
--- a/xdiff/xhistogram.c
+++ b/xdiff/xhistogram.c
@@ -129,7 +129,7 @@ static int scanA(struct histindex *index, int line1, int count1)
 				NEXT_PTR(index, ptr) = rec->ptr;
 				rec->ptr = ptr;
 				/* cap rec->cnt at MAX_CNT */
-				rec->cnt = XDL_MIN(MAX_CNT, rec->cnt + 1);
+				rec->cnt = MIN(MAX_CNT, rec->cnt + 1);
 				LINE_MAP(index, ptr) = rec;
 				goto continue_scan;
 			}
@@ -193,14 +193,14 @@ static int try_lcs(struct histindex *index, struct region *lcs, int b_ptr,
 				as--;
 				bs--;
 				if (1 < rc)
-					rc = XDL_MIN(rc, CNT(index, as));
+					rc = MIN(rc, CNT(index, as));
 			}
 			while (ae < LINE_END(1) && be < LINE_END(2)
 				&& CMP(index, 1, ae + 1, 2, be + 1)) {
 				ae++;
 				be++;
 				if (1 < rc)
-					rc = XDL_MIN(rc, CNT(index, ae));
+					rc = MIN(rc, CNT(index, ae));
 			}
 
 			if (b_next <= be)
diff --git a/xdiff/xmacros.h b/xdiff/xmacros.h
index 2809a28ca9..495b9dfac4 100644
--- a/xdiff/xmacros.h
+++ b/xdiff/xmacros.h
@@ -23,10 +23,8 @@
 #if !defined(XMACROS_H)
 #define XMACROS_H
 
+#include "../git-compat-util.h"
 
-
-
-#define XDL_MIN(a, b) ((a) < (b) ? (a): (b))
 #define XDL_MAX(a, b) ((a) > (b) ? (a): (b))
 #define XDL_ABS(v) ((v) >= 0 ? (v): -(v))
 #define XDL_ISDIGIT(c) ((c) >= '0' && (c) <= '9')
diff --git a/xdiff/xprepare.c b/xdiff/xprepare.c
index abeb8fb84e..7436064498 100644
--- a/xdiff/xprepare.c
+++ b/xdiff/xprepare.c
@@ -451,7 +451,7 @@ static int xdl_trim_ends(xdfile_t *xdf1, xdfile_t *xdf2) {
 
 	recs1 = xdf1->recs;
 	recs2 = xdf2->recs;
-	for (i = 0, lim = XDL_MIN(xdf1->nrec, xdf2->nrec); i < lim;
+	for (i = 0, lim = MIN(xdf1->nrec, xdf2->nrec); i < lim;
 	     i++, recs1++, recs2++)
 		if ((*recs1)->ha != (*recs2)->ha)
 			break;
-- 
2.19.1


  parent reply	other threads:[~2018-10-22  5:36 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-22  5:36 [RFC/PATCH 0/3] refactor MIN macro Carlo Marcelo Arenas Belón
2018-10-22  5:36 ` [PATCH 1/3] sha256: avoid redefinition for MIN Carlo Marcelo Arenas Belón
2018-10-22  6:00   ` Junio C Hamano
2018-10-22  5:36 ` [PATCH 2/3] git-compat-util: define MIN through compat Carlo Marcelo Arenas Belón
2018-10-22  6:13   ` Junio C Hamano
2018-10-22  6:41     ` Carlo Arenas
2018-10-22  5:36 ` Carlo Marcelo Arenas Belón [this message]
2018-10-22  5:59   ` [PATCH 3/3] xdiff: use compat's MIN instead Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181022053605.81048-4-carenas@gmail.com \
    --to=carenas@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=sandals@crustytoothpaste.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.