Compare commits

...

1 Commits

Author SHA1 Message Date
Markus Bergholz a18deddd2d ...not sure...looks ugly 5 years ago
  1. 18
      fastcompare.c

18
fastcompare.c

@ -14,6 +14,7 @@ long long int lines = 0, count_b = 0;
int main(int argc, char* argv[])
{
if (argc >= 3) {
FILE * fp;
char * line = NULL;
size_t len = 0;
@ -31,13 +32,22 @@ int main(int argc, char* argv[])
printf("start generating %d hashes for file %s\n", lines, argv[1]);
// memory optimization?
// line index is only needed with 4th input argument
int hashidx[2];
if (argc == 4) {
long int hashidx[lines];
}
// build in-memory hashes for the first file
long int hashes[lines], hashidx[lines];
long int hashes[lines];
lines = -1;
while ((read = getline(&line, &len, fp)) != -1) {
lines++;
hashes[lines] = crc32(0, (const void*)line, len);
hashidx[lines] = lines;
if (argc == 4) {
hashidx[lines] = lines;
}
}
//fclose(fp);
@ -73,7 +83,9 @@ int main(int argc, char* argv[])
// max iterator to reduce max iterator next round :)
if (lines >= 0) {
hashes[n] = hashes[lines];
hashidx[n] = hashidx[lines];
#ifdef indexcache
hashidx[n] = hashidx[lines];
#endif
lines--;
}
break;

Loading…
Cancel
Save