remove ssids in match
[spider.git] / perl / Prefix.pm
index 484f462ac24feee8bc338acedd703c79207de3df..ef748b6722b32406c7a918dc36a67566d0e42dfb 100644 (file)
@@ -148,9 +148,11 @@ sub matchprefix
        my $pref = shift;
        my @partials;
 
+       $pref =~ s/-\d+$//;
        for (my $i = length $pref; $i; $i--) {
                $matchtotal++;
                my $s = substr($pref, 0, $i);
+               push @partials, $s;
                my $p = $cache{$s};
                if ($p) {
                        $hits++;
@@ -158,10 +160,10 @@ sub matchprefix
                                my $percent = sprintf "%.1f", $hits * 100 / $misses;
                                dbg("Partial Prefix Cache Hit: $s Hits: $hits/$misses of $matchtotal = $percent\%");
                        }
+                       $cache{$_} = $p for @partials;
                        return @$p;
                } else {
                        $misses++;
-                       push @partials, $s;
                        my @out = get($s);
                        if (isdbg('prefix')) {
                                my $part = $out[0] || "*";
@@ -169,7 +171,7 @@ sub matchprefix
                                dbg("Partial prefix: $pref $s $part" );
                        } 
                        if (@out && $out[0] eq $s) {
-                               $cache{$_} = [ @out ] for @partials;
+                               $cache{$_} =  \@out for @partials;
                                return @out;
                        } 
                }