git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: apodtele <apodtele@gmail.com>
To: git@vger.kernel.org
Subject: [PATCH 1/2] diff --stat: use asymptotic scaling in graph
Date: Thu, 12 Oct 2006 15:37:17 -0400	[thread overview]
Message-ID: <d620685f0610121237k458665c5m7bbde2d565d7ef81@mail.gmail.com> (raw)

Instead of conditionally scaling the stat graph for large changes,
always scale it asymptotically: small changes shall appear without any
distortions.

Signed-off-by: Alexei Podtelezhnikov

--- diff.c	2006-10-12 14:45:13.000000000 -0400
+++ diff.c	2006-10-12 15:07:30.000000000 -0400
@@ -637,15 +637,9 @@

 const char mime_boundary_leader[] = "------------";

-static int scale_linear(int it, int width, int max_change)
+static int scale_nonlinear(int it, int width)
 {
-	/*
-	 * make sure that at least one '-' is printed if there were deletions,
-	 * and likewise for '+'.
-	 */
-	if (max_change < 2)
-		return it;
-	return ((it - 1) * (width - 1) + max_change - 1) / (max_change - 1);
+	return it * width / (it + width) + 1;
 }

 static void show_name(const char *prefix, const char *name, int len,
@@ -776,11 +770,9 @@
 		adds += add;
 		dels += del;

-		if (width <= max_change) {
-			add = scale_linear(add, width, max_change);
-			del = scale_linear(del, width, max_change);
-			total = add + del;
-		}
+		add = scale_nonlinear(add, width / 2);
+		del = scale_nonlinear(del, width / 2);
+		total = add + del;
 		show_name(prefix, name, len, reset, set);
 		printf("%5d ", added + deleted);
 		show_graph('+', add, add_c, reset);

             reply	other threads:[~2006-10-12 19:37 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-12 19:37 apodtele [this message]
2006-10-12 20:16 ` [PATCH 1/2] diff --stat: use asymptotic scaling in graph Martin Waitz
2006-10-12 21:37   ` apodtele
2006-10-12 22:20     ` A Large Angry SCM
2006-10-12 22:27       ` Martin Waitz
2006-10-12 22:48         ` A Large Angry SCM
2006-10-12 22:52           ` Johannes Schindelin
2006-10-12 23:12             ` apodtele
2006-10-13  0:39           ` Nicolas Pitre
2006-10-13 13:25             ` apodtele
2006-10-13 13:31               ` Andy Whitcroft
2006-10-12 21:53 ` Junio C Hamano
2006-10-12 22:15   ` A Large Angry SCM
2006-10-12 22:24   ` Junio C Hamano
2006-10-13 13:56   ` apodtele
2006-10-14 19:06     ` 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=d620685f0610121237k458665c5m7bbde2d565d7ef81@mail.gmail.com \
    --to=apodtele@gmail.com \
    --cc=git@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).