Cache symlink lookups. 5-10% speed improvement.
authorMikko Värri <vmj@linuxbox.fi>
Tue, 27 Sep 2011 00:19:47 +0000 (03:19 +0300)
committerMikko Värri <vmj@linuxbox.fi>
Tue, 27 Sep 2011 00:19:47 +0000 (03:19 +0300)
lib/Slackware/Cache.pm
lib/Slackware/File.pm

index b8ced14..f9319e5 100644 (file)
@@ -30,6 +30,17 @@ my %files;
 # "usr/bin/biff" => [ '/var/log/packages/biff+comsat-0.17-x64_64-1' ]
 my %file_providers;
 
+# "/usr/bin/biff" => "/usr/bin/biff-1.0"
+my %symlink;
+
+sub readlink {
+    my $name = shift;
+    return $symlink{$name} if defined $symlink{$name};
+    $symlink{$name} = `readlink -f $name`;
+    return $symlink{$name};
+}
+
+
 
 sub get_file {
     my $root = shift;
index 43bd78d..44435c7 100644 (file)
@@ -145,7 +145,7 @@ sub required_shared_libraries {
         $line =~ s[\s*\(0x[0-9a-fA-F]+\)$][];
         next unless $line;
         if ( -l "$line" ) {
-            my $dest = `readlink -f $line`;
+            my $dest = Slackware::Cache::readlink($line);
             chomp($dest);
             $line = $dest;
         }