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

Dpkg::Vendor: Cache vendor info Control::Hash objects

Avoid parsing again the current vendor file on each hook invocation,
by caching the parsed object into a hash.
Guillem Jover лет назад: 12
Родитель
Сommit
82d38b898e
2 измененных файлов с 6 добавлено и 0 удалено
  1. 2 0
      debian/changelog
  2. 4 0
      scripts/Dpkg/Vendor.pm

+ 2 - 0
debian/changelog

@@ -38,6 +38,8 @@ dpkg (1.17.7) UNRELEASED; urgency=low
     source control file to fill the «profile» value.
   * Do not interpret the .dsc filename as a regex when recomputing the
     md5sum for the .changes file after signing the .dsc. Closes: #742535
+  * Cache vendor info Control::Hash objects in Dpkg::Vendor::get_vendor_info()
+    when parsing the vendor file on each hook invocation.
 
   [ Updated dpkg translations ]
   * German (Sven Joachim).

+ 4 - 0
scripts/Dpkg/Vendor.pm

@@ -81,12 +81,16 @@ if there's no file for the given vendor.
 
 =cut
 
+my %VENDOR_CACHE;
 sub get_vendor_info(;$) {
     my $vendor = shift || 'default';
+    return $VENDOR_CACHE{$vendor} if exists $VENDOR_CACHE{$vendor};
+
     my $file = get_vendor_file($vendor);
     return unless $file;
     my $fields = Dpkg::Control::HashCore->new();
     $fields->load($file) or error(_g('%s is empty'), $file);
+    $VENDOR_CACHE{$vendor} = $fields;
     return $fields;
 }