From 2bd3416b329ab80c5c9d0e384a92da92e2784252 Mon Sep 17 00:00:00 2001 From: Nigel Horne Date: Fri, 25 Oct 2024 21:36:59 -0400 Subject: [PATCH] Added some code comments and small optimisations --- gedcom | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/gedcom b/gedcom index 058179c..d93c087 100755 --- a/gedcom +++ b/gedcom @@ -11320,20 +11320,20 @@ sub get_all_residences return @{$all_residences{$person->xref()}}; } - my @residences = $person->residence(); my @rc; my $index = 0; - foreach my $residence(@residences) { + + for my $residence ($person->residence()) { $index++; - if(!ref($residence)) { + + # Attempt to resolve non-object residence to a Gedcom::Record object + unless (ref $residence) { my $r = $person->tag_record('RESI', $index); - if(ref($r) eq 'Gedcom::Record') { - $residence = $r; - } - } - if(ref($residence) eq 'Gedcom::Record') { - push @rc, $residence; + $residence = $r if $r->isa('Gedcom::Record'); } + + # Add valid Gedcom::Record residences to the results array + push @rc, $residence if $residence->isa('Gedcom::Record'); } my @events = $person->event(); $index = 0; @@ -13952,13 +13952,13 @@ sub get_params # Populate %rc based on the number and type of arguments if(($num_args == 1) && (defined $default)) { - %rc = ($default => shift); + return { $default => shift }; } elsif(($num_args % 2) == 0) { %rc = @_; } elsif($num_args == 1) { - Carp::croak("Usage: ", __PACKAGE__, "->", (caller(1))[3], "()"); + Carp::croak('Usage: ', __PACKAGE__, '->', (caller(1))[3], '()'); } elsif($num_args == 0 && defined $default) { - Carp::croak("Usage: ", __PACKAGE__, "->", (caller(1))[3], "($default => \$val)"); + Carp::croak('Usage: ', __PACKAGE__, '->', (caller(1))[3], '($default => \$val)'); } return \%rc;