So _that's_ why mkfiles.pl was running so slowly on my Windows box!
authorsimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Sat, 17 Jan 2004 13:24:59 +0000 (13:24 +0000)
committersimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Sat, 17 Jan 2004 13:24:59 +0000 (13:24 +0000)
&findfile() now caches its results. At least one full order of
magnitude speedup when running on an SMB-mounted volume. Phew.

git-svn-id: svn://svn.tartarus.org/sgt/putty@3720 cda61777-01e9-0310-a592-d414129be87e

mkfiles.pl

index 30bd680..652d2ec 100755 (executable)
@@ -184,12 +184,15 @@ foreach $i (keys %depends) {
 sub findfile {
   my ($name) = @_;
   my $dir, $i, $outdir = "";
-  $i = 0;
-  foreach $dir (@incdirs) {
-    $outdir = $dir, $i++ if -f "$dir$name";
+  unless (defined $findfilecache{$name}) {
+    $i = 0;
+    foreach $dir (@incdirs) {
+      $outdir = $dir, $i++ if -f "$dir$name";
+    }
+    die "multiple instances of source file $name\n" if $i > 1;
+    $findfilecache{$name} = $outdir . $name;
   }
-  die "multiple instances of source file $name\n" if $i > 1;
-  return "$outdir$name";
+  return $findfilecache{$name};
 }
 
 sub objects {