From: Nicholas Clark Date: Mon, 8 Jul 2013 13:12:28 +0000 (+0200) Subject: Refactor ExtUtils::Embed::xsi_{protos,body} to use a scalar $retval. X-Git-Tag: upstream/5.20.0~2766^2~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2d7ce4f0bbc68d324277c4383a6ad0a316c0b651;p=platform%2Fupstream%2Fperl.git 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. --- diff --git a/lib/ExtUtils/Embed.pm b/lib/ExtUtils/Embed.pm index 71c3876..09b2ddd 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 {