Update of /cvsroot/fink/fink/perlmod/Fink
In directory sc8-pr-cvs1:/tmp/cvs-serv9666

Modified Files:
        ChangeLog Package.pm 
Log Message:
Carsten Klapp's patch to speed up search_comparedb and update_db, which speeds up many 
fink commands a bit (Patch #674313).

Index: ChangeLog
===================================================================
RCS file: /cvsroot/fink/fink/perlmod/Fink/ChangeLog,v
retrieving revision 1.251
retrieving revision 1.252
diff -u -r1.251 -r1.252
--- ChangeLog   24 Jan 2003 11:29:27 -0000      1.251
+++ ChangeLog   24 Jan 2003 22:14:04 -0000      1.252
@@ -1,4 +1,7 @@
 2003-01-24  Max Horn  <[EMAIL PROTECTED]>
+
+       * Package.pm: Carsten Klapp's patch to speed up search_comparedb and
+         update_db, which speeds up many fink commands a bit (Patch #674313).
        
        * Services.pm: Tiny optimization in expand_percent.
        

Index: Package.pm
===================================================================
RCS file: /cvsroot/fink/fink/perlmod/Fink/Package.pm,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- Package.pm  22 Jan 2003 23:46:23 -0000      1.29
+++ Package.pm  24 Jan 2003 22:14:04 -0000      1.30
@@ -394,25 +394,24 @@
 
 sub search_comparedb {
   my $path = shift;
-  my (@files, $file, $newpath, @stats);
+  my (@files, $file, $fullpath, @stats);
 
+  # FIXME: should probably just check dirs of $config->get_treelist()
   opendir(DIR, $path) || die "can't opendir $path: $!";
-  @files = readdir(DIR);
+  @files = grep { !/^[\.#]/ } readdir(DIR);
   closedir DIR;
-  
-  foreach $file (@files) {
-    next if substr($file, 0, 1) eq ".";
-    next if $file eq "CVS";
-    
-    $newpath = "$path/$file"; 
 
-    @stats = stat($newpath);
+  foreach $file (@files) {
+    $fullpath = "$path/$file"; 
 
-    if (S_ISDIR($stats[2])) {
-      return 1 if (&search_comparedb($newpath));
+    if (-d $fullpath) {
+      next if $file eq "binary-darwin-powerpc";
+      next if $file eq "CVS";
+      return 1 if (&search_comparedb($fullpath));
     }
-    
-    if (substr($file, length($file)-5) eq ".info") {
+    else {
+      next if !(substr($file, length($file)-5) eq ".info");
+      @stats = stat($fullpath);
       return 1 if ($stats[9] > $db_mtime);
     }
   }
@@ -425,18 +424,16 @@
 sub update_db {
   shift;  # class method - ignore first parameter
   my ($tree, $dir);
-  
-  print "Reading package info...\n";
-  
-  # read data from descriptions
-  foreach $tree ($config->get_treelist()) {
-    $dir = "$basepath/fink/dists/$tree/finkinfo";
-    Fink::Package->scan($dir);
-  }
-  
+
   eval {
     require Storable; 
     if ($> == 0) {
+      # read data from descriptions
+      print "Reading package info...\n";
+      foreach $tree ($config->get_treelist()) {
+        $dir = "$basepath/fink/dists/$tree/finkinfo";
+        Fink::Package->scan($dir);
+      }
       print "Updating package index... ";
       unless (-d "$basepath/var/db") {
         mkdir("$basepath/var/db", 0755) || die "Error: Could not create directory 
$basepath/var/db";



-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com
_______________________________________________
Fink-commits mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/fink-commits

Reply via email to