1. tidy up AUTOLOAD
[spider.git] / perl / Prefix.pm
index 5733ff0254c689dabde03a16371b1f412b442d48..1e6e50c2d2e97baa42b7f8dc776b693113bf7d8f 100644 (file)
@@ -31,9 +31,7 @@ $db = undef;                                  # the DB_File handle
 %prefix_loc = ();                              # the meat of the info
 %pre = ();                                             # the prefix list
 $hits = $misses = $matchtotal = 1;             # cache stats
-$lrusize = 2000;                               # size of prefix LRU cache
-
-$lru = LRU->newbase('Prefix', $lrusize);
+$lrusize = 1000;                               # size of prefix LRU cache
 
 sub load
 {
@@ -43,6 +41,8 @@ sub load
                untie %pre;
                %pre = ();
                %prefix_loc = ();
+               $lru->close if $lru;
+               undef $lru;
        }
 
        # tie the main prefix database
@@ -50,6 +50,7 @@ sub load
        my $out = $@ if $@;
        do "$main::data/prefix_data.pl" if !$out;
        $out = $@ if $@;
+       $lru = LRU->newbase('Prefix', $lrusize);
 
        return $out;
 }
@@ -452,7 +453,6 @@ my %valid = (
 
 sub AUTOLOAD
 {
-       my $self = shift;
        no strict;
        my $name = $AUTOLOAD;
   
@@ -463,7 +463,7 @@ sub AUTOLOAD
        # this clever line of code creates a subroutine which takes over from autoload
        # from OO Perl - Conway
        *$AUTOLOAD = sub {@_ > 1 ? $_[0]->{$name} = $_[1] : $_[0]->{$name}} ;
-       &$AUTOLOAD($self, @_);
+       goto &$AUTOLOAD;
 }
 
 #