From: Peter O. <obe...@us...> - 2014-01-08 13:26:07
|
Update of /cvsroot/ltp/utils/analysis/lcov/bin In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv24803 Modified Files: genhtml Log Message: genhtml: Reduce hash copying while adding up files Reduce copying effort and memory usage. Based on similar patch for lcov by ol...@su.... Signed-off-by: Peter Oberparleiter <ob...@li...> Index: genhtml =================================================================== RCS file: /cvsroot/ltp/utils/analysis/lcov/bin/genhtml,v retrieving revision 1.76 retrieving revision 1.77 diff -C2 -d -r1.76 -r1.77 *** genhtml 13 Mar 2013 10:28:07 -0000 1.76 --- genhtml 8 Jan 2014 13:26:04 -0000 1.77 *************** *** 1836,1841 **** sub add_counts($$) { ! my %data1 = %{$_[0]}; # Hash 1 ! my %data2 = %{$_[1]}; # Hash 2 my %result; # Resulting hash my $line; # Current line iteration scalar --- 1836,1841 ---- sub add_counts($$) { ! my $data1_ref = $_[0]; # Hash 1 ! my $data2_ref = $_[1]; # Hash 2 my %result; # Resulting hash my $line; # Current line iteration scalar *************** *** 1845,1852 **** my $hit = 0; # Number of lines with a count > 0 ! foreach $line (keys(%data1)) { ! $data1_count = $data1{$line}; ! $data2_count = $data2{$line}; # Add counts if present in both hashes --- 1845,1852 ---- my $hit = 0; # Number of lines with a count > 0 ! foreach $line (keys(%$data1_ref)) { ! $data1_count = $data1_ref->{$line}; ! $data2_count = $data2_ref->{$line}; # Add counts if present in both hashes *************** *** 1860,1871 **** } ! # Add lines unique to data2 ! foreach $line (keys(%data2)) { ! # Skip lines already in data1 ! if (defined($data1{$line})) { next; } ! # Copy count from data2 ! $result{$line} = $data2{$line}; $found++; --- 1860,1871 ---- } ! # Add lines unique to data2_ref ! foreach $line (keys(%$data2_ref)) { ! # Skip lines already in data1_ref ! if (defined($data1_ref->{$line})) { next; } ! # Copy count from data2_ref ! $result{$line} = $data2_ref->{$line}; $found++; |