diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2003-08-13 20:44:16 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2003-08-13 20:44:16 +0000 |
commit | 58ab6ec09fad80fac41913b2102e3aa35a17ccfb (patch) | |
tree | c2b9f421a4f8a8e0655d1d021e5341e0714d7631 /usr.bin/diff/diffreg.c | |
parent | f63801f57bcd7a3a97f7bed3758105fc9c51763a (diff) |
Based on what otto@ said on icb. The expensive thing in diff is
newcand() (this is what blows up the memory usage so badly). Instead
of counting how many times we go through the loop, count how many
times we called newcand(). I renamed loopcount -> numtries since
it is no longer the number of loop runs. This fixes espie@'s regression.
tedu@ OK
Diffstat (limited to 'usr.bin/diff/diffreg.c')
-rw-r--r-- | usr.bin/diff/diffreg.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/usr.bin/diff/diffreg.c b/usr.bin/diff/diffreg.c index daaf6d7747a..b21c4815f3c 100644 --- a/usr.bin/diff/diffreg.c +++ b/usr.bin/diff/diffreg.c @@ -1,4 +1,4 @@ -/* $OpenBSD: diffreg.c,v 1.48 2003/08/08 16:09:26 otto Exp $ */ +/* $OpenBSD: diffreg.c,v 1.49 2003/08/13 20:44:15 millert Exp $ */ /* * Copyright (C) Caldera International Inc. 2001-2002. @@ -65,7 +65,7 @@ */ #ifndef lint -static const char rcsid[] = "$OpenBSD: diffreg.c,v 1.48 2003/08/08 16:09:26 otto Exp $"; +static const char rcsid[] = "$OpenBSD: diffreg.c,v 1.49 2003/08/13 20:44:15 millert Exp $"; #endif /* not lint */ #include <sys/param.h> @@ -634,7 +634,7 @@ stone(int *a, int n, int *b, int *c) { int i, k, y, j, l; int oldc, tc, oldl; - u_int loopcount; + u_int numtries; const u_int bound = dflag ? UINT_MAX : max(256, isqrt(n)); @@ -647,9 +647,8 @@ stone(int *a, int n, int *b, int *c) y = -b[j]; oldl = 0; oldc = c[0]; - loopcount = 0; + numtries = 0; do { - loopcount++; if (y <= clist[oldc].y) continue; l = search(c, k, y); @@ -662,12 +661,13 @@ stone(int *a, int n, int *b, int *c) c[l] = newcand(i, y, oldc); oldc = tc; oldl = l; + numtries++; } else { c[l] = newcand(i, y, oldc); k++; break; } - } while ((y = b[++j]) > 0 && loopcount < bound); + } while ((y = b[++j]) > 0 && numtries < bound); } return (k); } |