sub matchprefix
{
my $pref = shift;
+ my @partials;
for (my $i = length $pref; $i; $i--) {
$matchtotal++;
if ($p) {
$hits++;
if (isdbg('prefix')) {
- my $percent = $hits * 100 / $matchtotal;
+ my $percent = sprintf "%.1f", $hits * 100 / $matchtotal;
dbg("Partial Prefix Cache Hit: $s Hits: $hits of $matchtotal = $percent\%");
}
return @$p;
} else {
+ push @partials, $s;
my @out = get($s);
if (isdbg('prefix')) {
my $part = $out[0] || "*";
dbg("Partial prefix: $pref $s $part" );
}
if (@out && $out[0] eq $s) {
- $cache{$s} = \@out;
+ $cache{$_} = \@out for @partials;
return @out;
- }
+ }
}
}
return ();
# clear out the cache periodically to stop it growing for ever.
if ($main::systime - $lasttime >= 15*60) {
if (isdbg('prefix')) {
- my $percent = $hits * 100 / $matchtotal;
+ my $percent = sprintf "%.1f", $hits * 100 / $matchtotal;
dbg("Prefix Cache Cleared, Hits: $hits of $matchtotal = $percent\%") ;
}
- my $percent = $hits * 100 / $matchtotal;
- dbg("Prefix Cache Cleared, $percent\% hits") if isdbg('prefix');
%cache =();
$lasttime = $main::systime;
$hits = $matchtotal = 0;
if ($p) {
$hits++;
if (isdbg('prefix')) {
- my $percent = $hits * 100 / $matchtotal;
+ my $percent = sprintf "%.1f", $hits * 100 / $matchtotal;
dbg("Prefix Cache Hit: $call Hits: $hits of $matchtotal = $percent\%");
}
push @out, @$p;
push @out, @nout;
}
- if (isdbg('prefix')) {
+ if (isdbg('prefixdata')) {
my $dd = new Data::Dumper([ \@out ], [qw(@out)]);
dbg($dd->Dumpxs);
}