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

Dpkg::Shlibs::SymbolFile::get_new_symbols(): simplify and shorten code

Reduce the code in get_new_symbols() by enumerating symbols, rather than their
names. Also split off some code to Symbol::is_eligible_as_new() function.

Patch is supposed to result in no behavioral changes.

Signed-off-by: Modestas Vainius <modax@debian.org>
Signed-off-by: Raphaël Hertzog <hertzog@debian.org>
Modestas Vainius лет назад: 16
Родитель
Сommit
2425566eb6
2 измененных файлов с 16 добавлено и 8 удалено
  1. 9 0
      scripts/Dpkg/Shlibs/Symbol.pm
  2. 7 8
      scripts/Dpkg/Shlibs/SymbolFile.pm

+ 9 - 0
scripts/Dpkg/Shlibs/Symbol.pm

@@ -436,4 +436,13 @@ sub mark_not_found_in_library {
     }
 }
 
+# Quickly checks if the symbol (or pattern) can be considered as new due to its
+# status or current environment settings.
+sub is_eligible_as_new {
+    my ($self, $arch) = @_;
+    return ! $self->{deprecated} &&
+           ! $self->is_optional() &&
+           $self->arch_is_concerned($arch);
+}
+
 1;

+ 7 - 8
scripts/Dpkg/Shlibs/SymbolFile.pm

@@ -439,16 +439,15 @@ sub get_new_symbols {
 	my $mysyms = $self->{objects}{$soname}{syms};
 	next if not exists $ref->{objects}{$soname};
 	my $refsyms = $ref->{objects}{$soname}{syms};
-	foreach my $sym (grep { not $mysyms->{$_}{deprecated} and
-	                        not $mysyms->{$_}->is_optional() and
-	                        $mysyms->{$_}->arch_is_concerned($self->{arch})
-                              } keys %{$mysyms})
+	foreach my $sym (grep { $_->is_eligible_as_new($self->{arch}) }
+	                      values %$mysyms)
 	{
-	    if ((not exists $refsyms->{$sym}) or
-		$refsyms->{$sym}{deprecated} or
-		not $refsyms->{$sym}->arch_is_concerned($self->{arch}) )
+	    my $refsym = $refsyms->{$sym->get_symbolname()};
+	    if ((not defined $refsym) or
+		$refsym->{deprecated} or
+		not $refsym->arch_is_concerned($self->{arch}) )
 	    {
-		push @res, $mysyms->{$sym}->sclone(soname => $soname);
+		push @res, $sym->sclone(soname => $soname);
 	    }
 	}
     }