Sort decomp files and only cmp files of same size
Sorting decomp files by size and we now only compare files of the
same size. This should significantly reduce the amount of files
compared and improve the performance.
We also never compare a file that is already declared a dup.
@@ -18,21 +18,28 @@ sub rem_dup_decomp_files
# decomposition files
opendir(F,$dirname);
#my @decompfiles = grep(/^piodecomp/,readdir(F));
- my @decompfile_info = map{ {FNAME=>$_, SIZE=>-s $_, IS_DUP=>0} } grep(/^piodecomp/,readdir(F));
+ my @decompfile_info_tmp = map{ {FNAME=>$_, SIZE=>-s $_, IS_DUP=>0} } grep(/^piodecomp/,readdir(F));
closedir(F);
+ my @decompfile_info = sort { $a->{SIZE} <=> $b->{SIZE} } @decompfile_info_tmp;
+ for(my $i=0; $i<=$#decompfile_info; $i++){
+ print "File : $decompfile_info[$i]->{FNAME} , size = $decompfile_info[$i]->{SIZE}\n";
+ }
+
my $rmfile=0;
# Compare the decomposition files to find
# duplicates - and delete the dups
for(my $i=0; $i<=$#decompfile_info; $i++){
my $file = $decompfile_info[$i]->{FNAME};
my $fsize = $decompfile_info[$i]->{SIZE};
+ next if($decompfile_info[$i]->{IS_DUP});
for(my $j=$i+1;$j<=$#decompfile_info;$j++){
my $nfile = $decompfile_info[$j]->{FNAME};
my $f2size = $decompfile_info[$j]->{SIZE};
+ next if($decompfile_info[$j]->{IS_DUP});
+ last if($fsize != $f2size);
if($verbose){
print "Comparing $file, size=$fsize, $nfile, size=$f2size\n";
}
- next if($decompfile_info[$j]->{IS_DUP});
if($fsize == $f2size){
open(F1,$file);
my @file1 = <F1>;
