[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[SCM] Debian package checker branch, master, updated. 2.4.3-20-g5b36419



The following commit has been merged in the master branch:
commit 5b36419d5040f8af89bf92440974c658d3fe69c0
Author: Niels Thykier <niels@thykier.net>
Date:   Wed Dec 22 09:59:42 2010 +0100

    Create a sorted file index for checks to use instead of sorting it
    themselves (Closes: #605844)
    
      * checks/*:
        + [NT] Use the new pre-sorted file index when iterating over files.
    
      * lib/Lintian/Collect/Binary.pm:
        + [NT] Create a sorted file index to avoid sorting it in the checks.
          (Closes: #605844)

diff --git a/checks/changelog-file b/checks/changelog-file
index 8147095..40f4b0f 100644
--- a/checks/changelog-file
+++ b/checks/changelog-file
@@ -79,7 +79,7 @@ for my $file (sort keys %{$info->file_info}) {
 }
 
 # Read package contents....  Capitalization errors are dealt with later.
-foreach (sort keys %{$info->index}) {
+foreach (@{$info->sorted_index}) {
     next unless length $_;
     # skip packages which have a /usr/share/doc/$pkg -> foo symlink
     if (m,usr/share/doc/$ppkg$, and defined $info->index->{$_}->{link}) {
diff --git a/checks/copyright-file b/checks/copyright-file
index 336d0f4..267ed43 100644
--- a/checks/copyright-file
+++ b/checks/copyright-file
@@ -45,7 +45,7 @@ my $found = 0;
 my $linked = 0;
 
 # Read package contents...
-foreach (sort keys %{$info->index}) {
+foreach (@{$info->sorted_index}) {
     my $index_info = $info->index->{$_};
     if (m,usr/(share/)?doc/$ppkg/copyright(\.\S+)?$,) {
 	my $ext = $2;
diff --git a/checks/etcfiles b/checks/etcfiles
index bc61715..9a734b1 100644
--- a/checks/etcfiles
+++ b/checks/etcfiles
@@ -45,7 +45,7 @@ if (open(IN, '<', $conffiles)) {
 }
 
 # Read package contents...
-foreach my $file (sort keys %{$info->index}) {
+foreach my $file (@{$info->sorted_index}) {
     my $index_info = $info->index->{$file};
     next unless $file =~ m,^etc, and $index_info->{type}=~ m/^[-h]/;
 
diff --git a/checks/fields b/checks/fields
index e503a52..af5fae5 100644
--- a/checks/fields
+++ b/checks/fields
@@ -503,7 +503,7 @@ if (defined $info->field('installer-menu-item')) {
 my $metapackage = 0;
 if ($type eq 'binary') {
 	$metapackage = 1;
-	for my $file (keys %{$info->index}) {
+	for my $file (@{$info->sorted_index}) {
 		next if $info->index->{$file}->{type} =~ /^d/;
 		next if $file =~ m%^usr/share/doc/%;
 		next if $file =~ m%^usr/share/lintian/overrides/%;
diff --git a/checks/files b/checks/files
index bdbd585..07b7fea 100644
--- a/checks/files
+++ b/checks/files
@@ -199,7 +199,7 @@ if ($description) {
     }
 }
 if ($is_empty) {
-    for my $file (sort keys %{$info->index}) {
+    for my $file (@{$info->sorted_index}) {
         # Ignore directories
         unless ($file =~ m,/$,) {
             # Skip if $file is an empty string
@@ -226,7 +226,7 @@ if ($is_empty) {
 }
 
 # Read package contents...
-foreach my $file (sort keys %{$info->index}) {
+foreach my $file (@{$info->sorted_index}) {
     next if $file eq "";
     my $index_info = $info->index->{$file};
     my $owner = $index_info->{owner} . '/' . $index_info->{group};
@@ -1204,7 +1204,7 @@ if ($pkg_section !~ m,games$, and $games > 0 and $other == 0) {
 # so just ignore them.
 #
 # python-support needs a directory for each package even it might be empty
-foreach my $dir (sort keys %{$info->index}) {
+foreach my $dir (@{$info->sorted_index}) {
     next if $dir eq "" or $info->index->{$dir}->{type} ne 'd';
     next if ($dir =~ m{^var/} or $dir =~ m{^etc/});
     next if $pkg eq 'base-files';
diff --git a/checks/infofiles b/checks/infofiles
index 2c5b994..872a74b 100644
--- a/checks/infofiles
+++ b/checks/infofiles
@@ -40,7 +40,7 @@ my %missing_section;
 my $has_info_file;
 
 # Read package contents...
-foreach my $file (sort keys %{$info->index}) {
+foreach my $file (@{$info->sorted_index}) {
     my $index_info = $info->index->{$file};
     my $file_info = $info->file_info->{$file};
     my $link = $index_info->{link} || '';
diff --git a/checks/manpages b/checks/manpages
index 0035bda..17912d2 100644
--- a/checks/manpages
+++ b/checks/manpages
@@ -40,7 +40,7 @@ my %link;
 my %manpage;
 
 # Read package contents...
-foreach my $file (sort keys %{$info->index}) {
+foreach my $file (@{$info->sorted_index}) {
     my $index_info = $info->index->{$file};
     my $file_info = $info->file_info->{$file};
     my $link = $index_info->{link} || '';
diff --git a/checks/menu-format b/checks/menu-format
index bbb4bc8..4e85dae 100644
--- a/checks/menu-format
+++ b/checks/menu-format
@@ -396,7 +396,7 @@ closedir MENUDIR;
 
 # Find the desktop files in the package for verification.
 my @desktop_files;
-foreach my $file (sort keys %{$info->index}) {
+foreach my $file (@{$info->sorted_index}) {
     my $index_info = $info->index->{$file};
     my $operm = $index_info->{operm};
 
diff --git a/checks/scripts b/checks/scripts
index 54aa37b..1acd2b0 100644
--- a/checks/scripts
+++ b/checks/scripts
@@ -312,7 +312,7 @@ my $pkg = shift;
 my $type = shift;
 my $info = shift;
 
-foreach (sort keys %{$info->index}) {
+foreach (@{$info->sorted_index}) {
     next if $_ eq "";
     my $index_info = $info->index->{$_};
     my $operm = $index_info->{operm};
@@ -1114,7 +1114,7 @@ for my $divert (keys %added_diversions) {
 
     if ($expand_diversions) {
 	tag 'diversion-for-unknown-file', $divert, "$script:$line"
-	    unless (grep { $_ =~ m/$divertrx/ } keys %{$info->index});
+	    unless (grep { $_ =~ m/$divertrx/ } @{$info->sorted_index});
     } else {
 	tag 'diversion-for-unknown-file', $divert, "$script:$line"
 	    unless (exists $info->index->{$divert});
diff --git a/checks/shared-libs b/checks/shared-libs
index 1450f4b..b266ba5 100644
--- a/checks/shared-libs
+++ b/checks/shared-libs
@@ -83,7 +83,7 @@ foreach my $file (sort keys %{$info->file_info}) {
 
 # 2nd step: read package contents
 
-for my $cur_file (sort keys %{$info->index}) {
+for my $cur_file (@{$info->sorted_index}) {
     # shared library?
     my $cur_file_data = $info->index->{$cur_file};
 
diff --git a/debian/changelog b/debian/changelog
index 4eec353..df45810 100755
--- a/debian/changelog
+++ b/debian/changelog
@@ -5,6 +5,8 @@ lintian (2.4.4) UNRELEASED; urgency=low
       - build-depends-on-specific-java-doc-package
       - depends-on-specific-java-doc-package
 
+  * checks/*:
+    + [NT] Use the new pre-sorted file index when iterating over files.
   * checks/binaries:
     + [RA] Exclude kfreebsd-kernel-di-{amd64,i386} from the
       embedded-zlib check since it's in the kernel.  (Closes: #593397)
@@ -53,6 +55,10 @@ lintian (2.4.4) UNRELEASED; urgency=low
   * debian/compat:
     + [NT] Bump debhelper comat to 7.
 
+  * lib/Lintian/Collect/Binary.pm:
+    + [NT] Create a sorted file index to avoid sorting it in the checks.
+      (Closes: #605844)
+
   * t/tests/{rules-not-makefile,scripts-missing-dep}:
     + [NT] Added new tests. (Closes: #607731)
 
diff --git a/lib/Lintian/Collect/Binary.pm b/lib/Lintian/Collect/Binary.pm
index 6b6feeb..bc297fb 100644
--- a/lib/Lintian/Collect/Binary.pm
+++ b/lib/Lintian/Collect/Binary.pm
@@ -122,6 +122,18 @@ sub index {
     return $self->{index};
 }
 
+# Returns sorted file index (eqv to sort keys %{$info->index}), except it is cached.
+sub sorted_index {
+    my ($self) = @_;
+    my $index;
+    my @result;
+    return $self->{sorted_index} if exists $self->{sorted_index};
+    $index = $self->index();
+    @result = sort keys %{$index};
+    $self->{sorted_index} = \@result;
+    return \@result;
+}
+
 # Returns the information from collect/file-info
 sub file_info {
     my ($self) = @_;

-- 
Debian package checker


Reply to: