]> thyrsus.com Git - comparator.git/commitdiff
Transplant some code back to report.c
authorEric S. Raymond <esr@thyrsus.com>
Thu, 11 Sep 2003 20:21:25 +0000 (20:21 +0000)
committerEric S. Raymond <esr@thyrsus.com>
Thu, 11 Sep 2003 20:21:25 +0000 (20:21 +0000)
main.c
report.c

diff --git a/main.c b/main.c
index 6f8037f38571341b684212c64c9857f9bb245bac..5e0e727f6c52a92ae11f9133f31c410493ee218d 100644 (file)
--- a/main.c
+++ b/main.c
@@ -362,7 +362,7 @@ main(int argc, char *argv[])
     int status, file_only, compile_only;
     struct scf_t       *scf;
     char *dir, *outfile;
-    struct sorthash_t *mp, *np;
+    struct sorthash_t *np;
 
     compile_only = file_only = 0;
     dir = outfile = NULL;
@@ -566,37 +566,6 @@ main(int argc, char *argv[])
        sort_hashes(sort_buffer, sort_count);
        report_time("Sort done");
 
-       if (debug)
-       {
-           puts("Chunk list before compaction.");
-           dump_array(sort_buffer, sort_count, NULL);
-       }
-
-       /*
-        * To reduce the size of the in-core working set, we do a 
-        * a pre-elimination of duplicates based on hash key alone, in
-        * linear time.  This may leave in the the array hashes that
-        * all point to the same tree.  We'll catch those in a later phase.
-        * The technique: first mark...
-        */
-       if (!HASHCMP(sort_buffer, sort_buffer+1))
-           sort_buffer[0].hash.start = UNIQUE_FLAG;
-       for (np = sort_buffer+1; np < sort_buffer + sort_count-1; np++)
-           if (!HASHCMP(np, np-1) && !HASHCMP(np, np+1))
-               np->hash.start = UNIQUE_FLAG;
-       if (!HASHCMP(sort_buffer+sort_count-2, sort_buffer+sort_count-1))
-           sort_buffer[sort_count-1].hash.start = UNIQUE_FLAG;
-       /* ...then sweep. */
-       for (mp = np = sort_buffer; np < sort_buffer + sort_count; np++)
-           if (np->hash.start != UNIQUE_FLAG && mp < np)
-               *mp++ = *np;
-       /* now we get to reduce the memory footprint */
-       report_time("Compaction reduced %d shreds to %d", 
-                   sort_count, mp - sort_buffer);
-       sort_count = mp - sort_buffer;
-       sort_buffer = (struct sorthash_t *)realloc(sort_buffer, 
-                              sizeof(struct sorthash_t)* sort_count);
-
        if (debug)
        {
            puts("Chunk list before reduction.");
index 99e6e5b18de0c34b4f2198084d0c9d45c5442f34..d0bda7dcad58ee19698aa7cdf01278d326df579f 100644 (file)
--- a/report.c
+++ b/report.c
@@ -107,6 +107,31 @@ struct match_t *reduce_matches(struct sorthash_t *obarray, int hashcount)
      unsigned int retry, nonuniques, progress;
      struct sorthash_t *mp, *np;
 
+       /*
+        * To reduce the size of the in-core working set, we do a 
+        * a pre-elimination of duplicates based on hash key alone, in
+        * linear time.  This may leave in the the array hashes that
+        * all point to the same tree.  We'll catch those in a later phase.
+        * The technique: first mark...
+        */
+       if (!HASHCMP(obarray, obarray+1))
+           obarray[0].hash.start = UNIQUE_FLAG;
+       for (np = obarray+1; np < obarray + hashcount-1; np++)
+           if (!HASHCMP(np, np-1) && !HASHCMP(np, np+1))
+               np->hash.start = UNIQUE_FLAG;
+       if (!HASHCMP(obarray+hashcount-2, obarray+hashcount-1))
+           obarray[hashcount-1].hash.start = UNIQUE_FLAG;
+       /* ...then sweep. */
+       for (mp = np = obarray; np < obarray + hashcount; np++)
+           if (np->hash.start != UNIQUE_FLAG && mp < np)
+               *mp++ = *np;
+       /* now we get to reduce the memory footprint */
+       report_time("Compaction reduced %d shreds to %d", 
+                   hashcount, mp - obarray);
+       hashcount = mp - obarray;
+       obarray = (struct sorthash_t *)realloc(obarray, 
+                              sizeof(struct sorthash_t)* hashcount);
+
      /* build list of hashes with more than one range associated with */
      nonuniques = progress = 0;
      fprintf(stderr, "%% Extracting duplicates...   ");