diff options
author | Tay Ray Chuan <rctay89@gmail.com> | 2011-07-12 14:10:27 +0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2011-07-12 09:30:00 -0700 |
commit | 86abba801575892a8a2b161aa29518c1ed05e1f1 (patch) | |
tree | e2a5a2264646e2bbde43dfd8bff10369daec7c5b /xdiff/xutils.c | |
parent | 9f37c275938e1fbca7165872dad039874add09cd (diff) | |
download | git-86abba801575892a8a2b161aa29518c1ed05e1f1.tar.gz git-86abba801575892a8a2b161aa29518c1ed05e1f1.tar.xz |
xdiff/xprepare: use a smaller sample size for histogram diff
For histogram diff, we can afford a smaller sample size and thus a
poorer estimate of the number of lines, as the hash table (rhash) won't
be filled up/grown. This is safe as the final count of lines (xdf.nrecs)
will be updated correctly anyway by xdl_prepare_ctx().
This gives us a small boost in performance.
Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'xdiff/xutils.c')
-rw-r--r-- | xdiff/xutils.c | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/xdiff/xutils.c b/xdiff/xutils.c index ded7c327d..a45e89bbe 100644 --- a/xdiff/xutils.c +++ b/xdiff/xutils.c @@ -24,10 +24,6 @@ -#define XDL_GUESS_NLINES 256 - - - long xdl_bogosqrt(long n) { long i; @@ -159,12 +155,12 @@ void *xdl_cha_next(chastore_t *cha) { } -long xdl_guess_lines(mmfile_t *mf) { +long xdl_guess_lines(mmfile_t *mf, long sample) { long nl = 0, size, tsize = 0; char const *data, *cur, *top; if ((cur = data = xdl_mmfile_first(mf, &size)) != NULL) { - for (top = data + size; nl < XDL_GUESS_NLINES;) { + for (top = data + size; nl < sample;) { if (cur >= top) { tsize += (long) (cur - data); if (!(cur = data = xdl_mmfile_next(mf, &size))) |