From 2c0ac2f810d0bc1ba1187150e079915adb0b91ba Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sun, 14 Sep 2003 16:36:37 +0000 Subject: [PATCH] compare_files calls drop to noise level. --- report.c | 76 ++++++++++++++++++++++++++++++++------------------------ 1 file changed, 44 insertions(+), 32 deletions(-) diff --git a/report.c b/report.c index ea00532..9d2a045 100644 --- a/report.c +++ b/report.c @@ -103,7 +103,7 @@ static int collapse_ranges(struct match_t *reduced, int nonuniques) /* collapse together overlapping ranges in the hit list */ { struct match_t *sp, *tp; - int removed = 0; + int spancount, removed = 0; /* * For two matches to be eligible for merger, all their filenames must @@ -134,52 +134,64 @@ static int collapse_ranges(struct match_t *reduced, int nonuniques) #endif /* DEBUG */ /* time to merge overlapping shreds */ - for (sp = reduced; sp < reduced + nonuniques; sp++) + spancount = 0; + for (sp = reduced; sp < reduced + nonuniques; sp++, spancount--) { - for (tp = sp + 1; !compare_files(sp, tp) && tp < reduced + nonuniques; tp++) - { + int remaining; + + if (spancount <= 0) + { + spancount = 0; + for (tp = sp + 1; + !compare_files(sp, tp) && tp < reduced + nonuniques; + tp++) + spancount++; + } + + for (tp = sp + 1, remaining = spancount; remaining--; tp++) + { #ifdef DEBUG - printf("Trying merge of %d into %d\n", tp-reduced, sp-reduced); + printf("Trying merge of %d into %d\n", tp-reduced, sp-reduced); #endif /* DEBUG */ - /* neither must have been deleted */ - if (!sp->nmatches || !tp->nmatches) - { + /* neither must have been deleted */ + if (!sp->nmatches || !tp->nmatches) + { #ifdef DEBUG - printf("Null match pointer: %d=%p, %d=%p\n", - sp-reduced, sp->matches, tp-reduced, tp->matches); + printf("Null match pointer: %d=%p, %d=%p\n", + sp-reduced, sp->matches, tp-reduced, tp->matches); #endif /* DEBUG */ - continue; - } + continue; + } - /* attempt the merge */ - if (merge_ranges(tp->matches, sp->matches, sp->nmatches)) - { + /* attempt the merge */ + if (merge_ranges(tp->matches, sp->matches, sp->nmatches)) + { #ifdef DEBUG - struct sorthash_t *rp; + struct sorthash_t *rp; - printf("*** Merged %d into %d\n", tp-reduced, sp-reduced); - for (rp=sp->matches; rp < sp->matches+sp->nmatches; rp++) - printf("%s:%d:%d\n",rp->file->name,rp->hash.start,rp->hash.end); + printf("*** Merged %d into %d\n", tp-reduced, sp-reduced); + for (rp=sp->matches; rp < sp->matches+sp->nmatches; rp++) + printf("%s:%d:%d\n",rp->file->name,rp->hash.start,rp->hash.end); #endif /* DEBUG */ - removed++; - sp->nmatches = 0; - } - } - } + removed++; + sp->nmatches = 0; + } + } + } #ifdef DEBUG - for (sp = reduced; sp < reduced + nonuniques; sp++) - { - struct sorthash_t *rp; + for (sp = reduced; sp < reduced + nonuniques; sp++) + { + struct sorthash_t *rp; - printf("Clique beginning at %d (%d):\n", sp - reduced, sp->nmatches); - for (rp = sp->matches; rp < sp->matches + sp->nmatches; rp++) - printf("%s:%d:%d\n", rp->file->name, rp->hash.start, rp->hash.end); - } + printf("Clique beginning at %d (%d):\n", sp - reduced, sp->nmatches); + for (rp = sp->matches; rp < sp->matches + sp->nmatches; rp++) + printf("%s:%d:%d\n", rp->file->name, rp->hash.start, rp->hash.end); + } #endif /* DEBUG */ - return(nonuniques - removed); + return(nonuniques - removed); } struct match_t *reduce_matches(struct sorthash_t *obarray, int *hashcountp) -- 2.43.0