projects
/
spider.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
speeded up search and load of dx spots (a lot)
[spider.git]
/
perl
/
spot.pm
diff --git
a/perl/spot.pm
b/perl/spot.pm
index 811a708034f471070d824e7a71d95cbe31a3f736..1d0ac75331c79d53ad0a48311489134acd600018 100644
(file)
--- a/
perl/spot.pm
+++ b/
perl/spot.pm
@@
-34,11
+34,14
@@
sub init
my $ref = spot->open(@first);
if ($ref) {
my $fh = $ref->{fh};
my $ref = spot->open(@first);
if ($ref) {
my $fh = $ref->{fh};
+ my @out = ();
while (<$fh>) {
chomp;
my @ent = split /\^/;
while (<$fh>) {
chomp;
my @ent = split /\^/;
- unshift @spot::table, [ @ent ]; # stick this ref to anon list on the FRONT of the table
- ++$count;
+
+ push @spot::table, \@ent; # stick this ref to anon list on the FRONT of the table
+
+ ++$count;
}
}
@first = julian->add(@first, 1);
}
}
@first = julian->add(@first, 1);
@@
-57,7
+60,7
@@
sub new
$spot[2] = 0 + $spot[2];
# save it on the front of the list
$spot[2] = 0 + $spot[2];
# save it on the front of the list
- unshift @spot::table,
[ @spot ]
;
+ unshift @spot::table,
\@spot
;
# compare dates to see whether need to open a other save file
my @date = julian->unixtoj($spot[2]);
# compare dates to see whether need to open a other save file
my @date = julian->unixtoj($spot[2]);
@@
-91,10
+94,11
@@
sub purge
#
sub search
{
#
sub search
{
- my ($pkg, $field, $expr) = @_;
+ my ($pkg, $field, $expr
, $from, $to
) = @_;
my $eval;
my @out;
my $ref;
my $eval;
my @out;
my $ref;
+ my $i;
dbg('spot', "input expr = $expr\n");
if ($field == 0 || $field == 2) { # numeric fields
dbg('spot', "input expr = $expr\n");
if ($field == 0 || $field == 2) { # numeric fields
@@
-106,7
+110,12
@@
sub search
# build up eval to execute
$eval = qq(foreach \$ref (\@spot::table) {
# build up eval to execute
$eval = qq(foreach \$ref (\@spot::table) {
- push \@out, \$ref if $expr;
+ next if \$i < \$from;
+ if ($expr) {
+ unshift(\@out, \$ref);
+ \$i++;
+ last if \$to && \$i >= \$to;
+ }
});
dbg('spot', "eval = $eval\n");
eval $eval; # execute it
});
dbg('spot', "eval = $eval\n");
eval $eval; # execute it