summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2013-07-08 15:12:28 +0200
committerNicholas Clark <nick@ccl4.org>2013-07-09 07:54:28 +0200
commit2d7ce4f0bbc68d324277c4383a6ad0a316c0b651 (patch)
tree10e4d866fbc3caee4c2074af038bf65de63bee5e /lib
parent8d68a8a555855e91bb1e6912e9ee30c136295672 (diff)
downloadperl-2d7ce4f0bbc68d324277c4383a6ad0a316c0b651.tar.gz
Refactor ExtUtils::Embed::xsi_{protos,body} to use a scalar $retval.
Previously the code was accumulating the return value by pushing lines onto an array @retval, then joining it to a single scalar on return. As nothing needs the individual lines, reduce the complexity by concatenating directly to a scalar.
Diffstat (limited to 'lib')
-rw-r--r--lib/ExtUtils/Embed.pm46
1 files changed, 26 insertions, 20 deletions
diff --git a/lib/ExtUtils/Embed.pm b/lib/ExtUtils/Embed.pm
index 71c3876016..09b2ddd44b 100644
--- a/lib/ExtUtils/Embed.pm
+++ b/lib/ExtUtils/Embed.pm
@@ -80,41 +80,47 @@ EOF
}
sub xsi_protos {
- my(@exts) = @_;
- my(@retval,%seen);
+ my @exts = @_;
+ my %seen;
+ my $retval = '';
foreach my $cname (canon('__', @exts)) {
- my($ccode) = "EXTERN_C void boot_${cname} (pTHX_ CV* cv);\n";
- next if $seen{$ccode}++;
- push(@retval, $ccode);
+ my $ccode = "EXTERN_C void boot_${cname} (pTHX_ CV* cv);\n";
+ $retval .= $ccode
+ unless $seen{$ccode}++;
}
- return join '', @retval;
+ return $retval;
}
sub xsi_body {
- my(@exts) = @_;
- my(@retval,%seen);
- push(@retval, " static const char file[] = __FILE__;\n")
+ my @exts = @_;
+ my %seen;
+ my $retval;
+ $retval .= " static const char file[] = __FILE__;\n"
if @exts;
- push(@retval, " dXSUB_SYS;\n");
- push(@retval, " PERL_UNUSED_CONTEXT;\n");
- push(@retval, "\n")
+ $retval .= <<'EOT';
+ dXSUB_SYS;
+ PERL_UNUSED_CONTEXT;
+EOT
+ $retval .= "\n"
if @exts;
foreach my $pname (canon('/', @exts)) {
- my($cname, $mname, $ccode);
- ($mname = $pname) =~ s!/!::!g;
- ($cname = $pname) =~ s!/!__!g;
+ next
+ if $seen{$pname}++;
+ (my $mname = $pname) =~ s!/!::!g;
+ (my $cname = $pname) =~ s!/!__!g;
+ my $fname;
if ($pname eq 'DynaLoader'){
# Must NOT install 'DynaLoader::boot_DynaLoader' as 'bootstrap'!
# boot_DynaLoader is called directly in DynaLoader.pm
- $ccode = " /* DynaLoader is a special case */\n newXS(\"${mname}::boot_${cname}\", boot_${cname}, file);\n";
- push(@retval, $ccode) unless $seen{$ccode}++;
+ $retval .= " /* DynaLoader is a special case */\n";
+ $fname = "${mname}::boot_DynaLoader";
} else {
- $ccode = " newXS(\"${mname}::bootstrap\", boot_${cname}, file);\n";
- push(@retval, $ccode) unless $seen{$ccode}++;
+ $fname = "${mname}::bootstrap";
}
+ $retval .= " newXS(\"$fname\", boot_${cname}, file);\n"
}
- return join '', @retval;
+ return $retval;
}
sub static_ext {