From: Peter O. <obe...@us...> - 2014-01-08 13:14:07
|
Update of /cvsroot/ltp/utils/analysis/lcov/bin In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv23878 Modified Files: lcov Log Message: lcov: Avoiding copying hashes passed to add_counts function This patch reduces memory usage - without it lcov was failing every time for me with out of memory errors in a VM with 1GB of RAM and 1GB of swap, but with it lcov completes every time. It's presumably also faster to avoid these copies. Signed-off-by: Olly Betts <ol...@su...> Index: lcov =================================================================== RCS file: /cvsroot/ltp/utils/analysis/lcov/bin/lcov,v retrieving revision 1.97 retrieving revision 1.98 diff -C2 -d -r1.97 -r1.98 *** lcov 1 Jul 2013 11:49:46 -0000 1.97 --- lcov 8 Jan 2014 13:14:05 -0000 1.98 *************** *** 1997,2002 **** sub add_counts($$) { ! my %data1 = %{$_[0]}; # Hash 1 ! my %data2 = %{$_[1]}; # Hash 2 my %result; # Resulting hash my $line; # Current line iteration scalar --- 1997,2002 ---- 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 *************** *** 2006,2013 **** 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 --- 2006,2013 ---- 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 *************** *** 2021,2032 **** } ! # 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++; --- 2021,2032 ---- } ! # 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++; |