gnuplot driver more efficient. while,shift -> firstidx,splice

Ignore-this: 78741ffed855a5122e14486000af4154

darcs-hash:20090811181852-0cb85-ca6a28ee8151f7c8671c0d69dce8f29ed481fe4f.gz
This commit is contained in:
Dima Kogan 2009-08-11 11:18:52 -07:00
parent 78b6147d86
commit 0dab1a0ec0

View File

@ -3,6 +3,7 @@ use strict;
use Getopt::Long; use Getopt::Long;
use Time::HiRes qw( usleep ); use Time::HiRes qw( usleep );
use IO::Handle; use IO::Handle;
use List::MoreUtils qw( first_index );
use Data::Dumper; use Data::Dumper;
autoflush STDOUT 1; autoflush STDOUT 1;
@ -215,9 +216,11 @@ sub cutOld
foreach (@curves) foreach (@curves)
{ {
my $xy = $_->{"data"}; my $xy = $_->{"data"};
while(@$xy && $xy->[0][0] < $oldestx)
if( @$xy )
{ {
shift @$xy; my $firstInWindow = first_index {$_->[0] >= $oldestx} @$xy;
splice( @$xy, 0, $firstInWindow ) unless $firstInWindow == -1;
} }
} }
} }