Skip to content

Commit e90f186

Browse files
committed
ParseXS: standard_typemap_locations(): use push
Currently this function builds a list of paths in reverse order, but *unshifts* each result one by one so that they end up in the right order. This commit switches the order of generation and *pushes* the result each time. The net result is the same, but its less cognitive load working out what's going on.
1 parent facf65b commit e90f186

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Utilities.pm

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -110,23 +110,27 @@ A list of F<typemap> pathnames.
110110
sub standard_typemap_locations {
111111
my $include_ref = shift;
112112

113-
my @tm = qw(typemap);
113+
my @tm;
114+
115+
# See function description above for why 'reverse' is used here.
116+
foreach my $dir (reverse @{$include_ref}) {
117+
my $file = File::Spec->catfile($dir, ExtUtils => 'typemap');
118+
push @tm, $file;
119+
}
114120

115121
my $updir = File::Spec->updir();
116122
foreach my $dir (
117-
File::Spec->catdir(($updir) x 1),
118-
File::Spec->catdir(($updir) x 2),
119-
File::Spec->catdir(($updir) x 3),
120123
File::Spec->catdir(($updir) x 4),
124+
File::Spec->catdir(($updir) x 3),
125+
File::Spec->catdir(($updir) x 2),
126+
File::Spec->catdir(($updir) x 1),
121127
) {
122-
unshift @tm, File::Spec->catfile($dir, 'typemap');
123-
unshift @tm, File::Spec->catfile($dir, lib => ExtUtils => 'typemap');
128+
push @tm, File::Spec->catfile($dir, lib => ExtUtils => 'typemap');
129+
push @tm, File::Spec->catfile($dir, 'typemap');
124130
}
125131

126-
foreach my $dir (@{ $include_ref}) {
127-
my $file = File::Spec->catfile($dir, ExtUtils => 'typemap');
128-
unshift @tm, $file;
129-
}
132+
push @tm, 'typemap';
133+
130134
return @tm;
131135
}
132136

0 commit comments

Comments
 (0)