From d4da05d116751a9e564cede71b4a962c04bc85f7 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Fri, 7 Sep 2012 14:25:21 +0000 Subject: [PATCH] Optimize the code which computes the column width. git-svn-id: http://lm-sensors.org/svn/i2c-tools/trunk@6067 7894878c-1315-0410-8ee3-d5d059ff63e0 --- eeprom/decode-dimms | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/eeprom/decode-dimms b/eeprom/decode-dimms index 821df7d..c23b211 100755 --- a/eeprom/decode-dimms +++ b/eeprom/decode-dimms @@ -1957,19 +1957,21 @@ sub line_has_same_values($) # Find out the longest value string to adjust the column width $sbs_col_width = 15; if ($opt_side_by_side && !$opt_html) { - for $current (0 .. $#dimm) { - my @output = @{$dimm[$current]->{output}}; - my $line; + my $line; + my $line_nr = @{$dimm[0]->{output}}; + + for ($line = 0; $line < $line_nr; $line++) { + next if $opt_merge && line_has_same_values($line); + my @strings; - for ($line = 0; $line < @output; $line++) { - next if $opt_merge && line_has_same_values($line); - my ($func, $label, $value) = @{$output[$line]}; + for $current (0 .. $#dimm) { + my $value = $dimm[$current]->{output}->[$line]->[2]; push @strings, split("\n", $value) if defined $value; } - foreach $line (@strings) { - my $len = length($line); + foreach my $line2 (@strings) { + my $len = length($line2); $sbs_col_width = $len if $len > $sbs_col_width; } }