Просмотр исходного кода

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
Родитель
Сommit
f789211ee9
1 измененных файлов с 2 добавлено и 2 удалено
  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");