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

dpkg-source: optimize diffing phase of a source package build

Optimize dpkg-source -b by avoiding many diff calls when not required.

Based-on-patch-by: Mike Hommey <mh@glandium.org>
Raphaël Hertzog лет назад: 16
Родитель
Сommit
de470a7d71
2 измененных файлов с 5 добавлено и 0 удалено
  1. 2 0
      debian/changelog
  2. 3 0
      scripts/Dpkg/Source/Patch.pm

+ 2 - 0
debian/changelog

@@ -72,6 +72,8 @@ dpkg (1.15.5) UNRELEASED; urgency=low
   * Remove extra quoting that should not be there while passing an exclude
     file to git ls-files during build of 3.0 (git) source package.
     Thanks to Courtney Bane for the patch. Closes: #551829
+  * Optimize dpkg-source -b by avoiding many diff calls when not required.
+    Thanks to Mike Hommey for the idea. Closes: #554689
 
   [ Updated dpkg translations ]
   * Czech (Miroslav Kure).

+ 3 - 0
scripts/Dpkg/Source/Patch.pm

@@ -32,6 +32,7 @@ use File::Find;
 use File::Basename;
 use File::Spec;
 use File::Path;
+use File::Compare;
 use Fcntl ':mode';
 #XXX: Needed for sub-second timestamps, require recent perl
 #use Time::HiRes qw(stat);
@@ -63,6 +64,8 @@ sub add_diff_file {
         my ($self, $old, $new) = @_;
         $self->_fail_with_msg($new, _g("binary file contents changed"));
     };
+    # Optimization to avoid forking diff if unnecessary
+    return 1 if compare($old, $new, 4096) == 0;
     # Default diff options
     my @options;
     if ($opts{"options"}) {