Skip to content

Commit a74bdee

Browse files
Peter Oberparleiteroberpar
authored andcommitted
genhtml: Reduce hash copying while adding up files
Reduce copying effort and memory usage. Based on similar patch for lcov by [email protected]. Signed-off-by: Peter Oberparleiter <[email protected]>
1 parent c6b4d91 commit a74bdee

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

bin/genhtml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ use Digest::MD5 qw(md5_base64);
7373

7474
# Global constants
7575
our $title = "LCOV - code coverage report";
76-
our $lcov_version = 'LCOV version 1.11 pre (CVS $Revision: 1.76 $)';
76+
our $lcov_version = 'LCOV version 1.11 pre (CVS $Revision: 1.77 $)';
7777
our $lcov_url = "http://ltp.sourceforge.net/coverage/lcov.php";
7878
our $tool_name = basename($0);
7979

@@ -1835,19 +1835,19 @@ sub set_info_entry($$$$$$$$$;$$$$$$)
18351835

18361836
sub add_counts($$)
18371837
{
1838-
my %data1 = %{$_[0]}; # Hash 1
1839-
my %data2 = %{$_[1]}; # Hash 2
1838+
my $data1_ref = $_[0]; # Hash 1
1839+
my $data2_ref = $_[1]; # Hash 2
18401840
my %result; # Resulting hash
18411841
my $line; # Current line iteration scalar
18421842
my $data1_count; # Count of line in hash1
18431843
my $data2_count; # Count of line in hash2
18441844
my $found = 0; # Total number of lines found
18451845
my $hit = 0; # Number of lines with a count > 0
18461846

1847-
foreach $line (keys(%data1))
1847+
foreach $line (keys(%$data1_ref))
18481848
{
1849-
$data1_count = $data1{$line};
1850-
$data2_count = $data2{$line};
1849+
$data1_count = $data1_ref->{$line};
1850+
$data2_count = $data2_ref->{$line};
18511851

18521852
# Add counts if present in both hashes
18531853
if (defined($data2_count)) { $data1_count += $data2_count; }
@@ -1859,14 +1859,14 @@ sub add_counts($$)
18591859
if ($data1_count > 0) { $hit++; }
18601860
}
18611861

1862-
# Add lines unique to data2
1863-
foreach $line (keys(%data2))
1862+
# Add lines unique to data2_ref
1863+
foreach $line (keys(%$data2_ref))
18641864
{
1865-
# Skip lines already in data1
1866-
if (defined($data1{$line})) { next; }
1865+
# Skip lines already in data1_ref
1866+
if (defined($data1_ref->{$line})) { next; }
18671867

1868-
# Copy count from data2
1869-
$result{$line} = $data2{$line};
1868+
# Copy count from data2_ref
1869+
$result{$line} = $data2_ref->{$line};
18701870

18711871
$found++;
18721872
if ($result{$line} > 0) { $hit++; }

0 commit comments

Comments
 (0)