Selaa lähdekoodia

Dpkg::Source::Patch::add_diff_directory(): small optimization

The calls to File::Spec->abs2rel() are relatively expensive and can be
avoided given that we control the find() invocation and can only receive
filenames below the scanned directory. They are replaced with simple
string extraction with substr(), it gives another 25% speed benefit on big
source packages.

Based-on-patch-by: Mike Hommey <mh@glandium.org>
Raphaël Hertzog 16 vuotta sitten
vanhempi
commit
f789211ee9
1 muutettua tiedostoa jossa 2 lisäystä ja 2 poistoa
  1. 2 2
      scripts/Dpkg/Source/Patch.pm

+ 2 - 2
scripts/Dpkg/Source/Patch.pm

@@ -148,7 +148,7 @@ sub add_diff_directory {
 
     my %files_in_new;
     my $scan_new = sub {
-        my $fn = File::Spec->abs2rel($_, $new);
+        my $fn = (length > length($new)) ? substr($_, length($new) + 1) : '.';
         return if &$diff_ignore($fn);
         $files_in_new{$fn} = 1;
         lstat("$new/$fn") || syserr(_g("cannot stat file %s"), "$new/$fn");
@@ -221,7 +221,7 @@ sub add_diff_directory {
         }
     };
     my $scan_old = sub {
-        my $fn = File::Spec->abs2rel($_, $old);
+        my $fn = (length > length($old)) ? substr($_, length($old) + 1) : '.';
         return if &$diff_ignore($fn);
         return if $files_in_new{$fn};
         lstat("$old/$fn") || syserr(_g("cannot stat file %s"), "$old/$fn");