From 016754c22c9ea37f25857c0ded629b053de34a35 Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Wed, 29 Jan 2020 18:26:29 +0100 Subject: [PATCH 1/1] prepare decremented hidemin value Avoid repeated calculation for cleaner code. --- barcat | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/barcat b/barcat index 88dc55c..0d843c1 100755 --- a/barcat +++ b/barcat @@ -122,6 +122,7 @@ $opt{'value-length'} = 1 if $opt{unmodified}; $opt{'signal-stat'} //= exists $SIG{INFO} ? 'INFO' : 'QUIT'; $opt{markers} //= '=avg >31.73v <68.27v +50v |0'; $opt{palette} //= $opt{color} && [31, 90, 32]; +$opt{hidemin} = ($opt{hidemin} || 1) - 1; $opt{input} = @ARGV && $ARGV[0] =~ m/\A[-0-9]/ ? \@ARGV : undef and undef $opt{interval}; @@ -191,7 +192,7 @@ sub sival { sub show_lines { -state $nr = $opt{hidemin} ? $opt{hidemin} - 1 : 0; +state $nr = $opt{hidemin}; @lines and @lines > $nr or return; @lines or return; @lines > $nr or return unless $opt{hidemin}; @@ -294,9 +295,9 @@ say $opt{palette} ? color(0) : '' if $opt{spark}; sub show_stat { if ($opt{hidemin} or $opt{hidemax}) { - $opt{hidemin} ||= 1; - $opt{hidemax} ||= @lines; - printf '%s of ', sum(grep {length} @values[$opt{hidemin} - 1 .. $opt{hidemax} - 1]) // 0; + printf '%s of ', sum(grep { length } + @values[$opt{hidemin} .. ($opt{hidemax} || @lines) - 1] + ) // 0; } if (@order) { my $total = sum @order; -- 2.30.0