From: Andrew Ruthven Date: Tue, 17 Jun 2008 21:42:25 +0000 (+1200) Subject: Move the limiting of how many auto expire shows to display to an outer loop. X-Git-Tag: 0.8.0~3 X-Git-Url: http://git.etc.gen.nz/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=339d3948b245e6b5da8927875cab35f1ef5e64d7;p=mythtv-status.git Move the limiting of how many auto expire shows to display to an outer loop. This stops us from building a MythTV::Program object for every show in the auto expire list, even those we aren't going to display. Thanks to Tom Metro for pointing out this needless work. --- diff --git a/bin/mythtv-status b/bin/mythtv-status index 3427286..4e495fa 100755 --- a/bin/mythtv-status +++ b/bin/mythtv-status @@ -223,12 +223,7 @@ my @blocks = ( 'type' => 'sub', 'defaults' => 'schedule', 'sub' => \&process_auto_expire, - 'filter' => { - 'startTime' => sub { - $auto_expire_count--; - return ($auto_expire_count < 0); - }, - }, + 'filter' => {}, # Over ride the default filter from 'schedule'. }, # Diskspace, before storage groups @@ -747,7 +742,7 @@ sub process_auto_expire { next if $show->{'progflags'} eq 'LiveTV'; my %vars = ( - 'title' => $show->{'parentid'}, + 'title' => $show->{'parentid'} || 'Unknown', 'startTime' => strftime("%FT%T", localtime($show->{'starttime'})), 'NODE_TEXT' => $show->{'description'}, 'subTitle' => $show->{'subtitle'}, @@ -759,6 +754,9 @@ sub process_auto_expire { my $str = substitute_vars($block, \%vars); push @lines, $str if defined $str; + + # Don't do more work than is required. + last if --$auto_expire_count <= 0; } return join("\n", @lines);