[PATCH 3/3] range-diff: only compute patch diff when patches are different

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

 



This is a pure optimization, probably with negligible impact. I'm not sure
if it is a good idea because it could obscure future bugs.
---
 range-diff.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/range-diff.c b/range-diff.c
index df2147ef79..343a71d3eb 100644
--- a/range-diff.c
+++ b/range-diff.c
@@ -388,7 +388,7 @@ static int are_diffs_equivalent(const char *a_diff, const char *b_diff) {
 	return 1;
 }
 
-static void output_pair_header(struct diff_options *diffopt,
+static char output_pair_header(struct diff_options *diffopt,
 			       int patch_no_width,
 			       struct strbuf *buf,
 			       struct strbuf *dashes,
@@ -456,6 +456,8 @@ static void output_pair_header(struct diff_options *diffopt,
 	strbuf_addf(buf, "%s\n", color_reset);
 
 	fwrite(buf->buf, buf->len, 1, diffopt->file);
+
+	return status;
 }
 
 static struct userdiff_driver section_headers = {
@@ -537,9 +539,9 @@ static void output(struct string_list *a, struct string_list *b,
 		/* Show matching LHS/RHS pair. */
 		if (j < b->nr) {
 			a_util = a->items[b_util->matching].util;
-			output_pair_header(diffopt, patch_no_width,
+			char status = output_pair_header(diffopt, patch_no_width,
 					   &buf, &dashes, a_util, b_util);
-			if (!(diffopt->output_format & DIFF_FORMAT_NO_OUTPUT)) {
+			if (!(diffopt->output_format & DIFF_FORMAT_NO_OUTPUT) && status != '=') {
 				patch_diff(a_util->patch, a_util->diff_offset, 
 						b_util->patch, b_util->diff_offset, diffopt);
 			        diffopt->ignore_regex_nr = ignoring_context_only_changes;
-- 
2.29.2




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux