From 2f9a6acdb31fb4954c6ad6a59ca22a6912d9999a Mon Sep 17 00:00:00 2001 From: Dima Kogan Date: Sun, 20 Oct 2019 18:57:11 -0700 Subject: [PATCH] Minor no-op refactoring The ID->curve hash %curveIndices is now called $curveFromID, and now gives you a curve reference, not an index to @curves I can thus reorder @curves as I like, and %curveFromID remains valid --- bin/feedgnuplot | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/bin/feedgnuplot b/bin/feedgnuplot index 4cdeebf..8b1f482 100755 --- a/bin/feedgnuplot +++ b/bin/feedgnuplot @@ -31,8 +31,8 @@ interpretCommandline(); # datastring my @curves = (); -# list mapping curve names to their indices in the @curves list -my %curveIndices = (); +# Maps a curve ID to the corresponding curve +my %curveFromID = (); # Whether any new data has arrived since the last replot my $haveNewData; @@ -1186,7 +1186,7 @@ sub getCurve my ($id) = @_; - if( !exists $curveIndices{$id} ) + if( !exists $curveFromID{$id} ) { push @curves, {# if we have a catch-all style and no specific style, use # the catch-all style @@ -1199,9 +1199,9 @@ sub getCurve datastring => '', datastring_meta => [], datastring_offset => 0}; # push a curve with no data and no options - $curveIndices{$id} = $#curves; + $curveFromID{$id} = $curves[-1]; - updateCurveOptions($curves[$#curves], $id); + updateCurveOptions($curves[-1], $id); # --xlen has a meaning if we're not plotting histograms at all or if we're @@ -1218,8 +1218,11 @@ sub getCurve print STDERR "--xlen only makes sense when plotting ONLY histograms or ONLY NON-histograms\n"; exit -1; } + + return $curves[-1]; } - return $curves[$curveIndices{$id}]; + + return $curveFromID{$id}; } sub addCurveOption