Skip to content

Commit

Permalink
Small optimisation to 'both_sides'
Browse files Browse the repository at this point in the history
  • Loading branch information
nigelhorne committed Jul 6, 2024
1 parent 94d60a9 commit e4f5000
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions ged2site
Original file line number Diff line number Diff line change
Expand Up @@ -2514,7 +2514,6 @@ sub print_person

# Calculate the average age of adults death on both sides of the family
if($me && ((my $age = $age_at_death->years()) >= 20)) {
my $fr;
my $mr;
if(my $mother = $me->mother()) {
if($mr = $mother->relationship($person)) {
Expand All @@ -2523,21 +2522,20 @@ sub print_person
}
}
if(my $father = $me->father()) {
if($fr = $father->relationship($person)) {
if(my $fr = $father->relationship($person)) {
$facts->{'fathers_side'}->{'age'} += $age;
$facts->{'fathers_side'}->{'count'}++;
if($mr) {
# Keep a tally of the number of people appearing on both sides
push @{$facts->{'both_sides'}->{'xrefs'}}, $person->xref();
$facts->{'both_sides'}->{'count'}++;
}
}
}
if($mr && $fr) {
# Keep a tally of the number of people appearing on both sides
push @{$facts->{'both_sides'}->{'xrefs'}}, $person->xref();
$facts->{'both_sides'}->{'count'}++;
}
}
} elsif($yob && $yod) {
# Calculate the average age of adults death on both sides of the family
if($me && ((my $age = ($yod - $yob)) >= 20)) {
my $fr;
my $mr;
if(my $mother = $me->mother()) {
if($mr = $mother->relationship($person)) {
Expand All @@ -2546,16 +2544,16 @@ sub print_person
}
}
if(my $father = $me->father()) {
if($fr = $father->relationship($person)) {
if(my $fr = $father->relationship($person)) {
$facts->{'fathers_side'}->{'age'} += $age;
$facts->{'fathers_side'}->{'count'}++;
if($mr) {
# Keep a tally of the number of people appearing on both sides
push @{$facts->{'both_sides'}->{'xrefs'}}, $person->xref();
$facts->{'both_sides'}->{'count'}++;
}
}
}
if($mr && $fr) {
# Keep a tally of the number of people appearing on both sides
push @{$facts->{'both_sides'}->{'xrefs'}}, $person->xref();
$facts->{'both_sides'}->{'count'}++;
}
}
}

Expand Down

0 comments on commit e4f5000

Please sign in to comment.