Skip to content

Commit 0f55cf9

Browse files
committed
ParseXS: refactor: reduce scope of targ_used field
Move this field from Node::xbody to Node::output_part, as it's only used while generating the code for the output part of the xsub. No functional change.
1 parent 1be2f76 commit 0f55cf9

File tree

1 file changed

+10
-10
lines changed
  • dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS

1 file changed

+10
-10
lines changed

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1649,12 +1649,12 @@ sub as_output_code {
16491649

16501650
if ( $pxs->{config_optimize}
16511651
&& ExtUtils::Typemaps::OutputMap->targetable($evalexpr)
1652-
&& !$xbody->{targ_used})
1652+
&& !$xbody->{output_part}{targ_used})
16531653
{
16541654
# So TARG is available for use.
16551655
$retvar = 'TARG';
16561656
# can only use TARG to return one value
1657-
$xbody->{targ_used} = 1;
1657+
$xbody->{output_part}{targ_used} = 1;
16581658

16591659
# Since we're using TARG for the return SV, see if we can use
16601660
# the TARG[iun] macros as appropriate to speed up setting it.
@@ -2254,11 +2254,6 @@ BEGIN { $build_subclass->('', # parent
22542254
'OUTPUT_SETMAGIC_state', # Bool: most recent value of SETMAGIC in an
22552255
# OUTPUT section.
22562256

2257-
2258-
# State during code emitting
2259-
2260-
'targ_used', # Bool: the TARG has been allocated for this body,
2261-
# so is no longer available for use.
22622257
)};
22632258

22642259

@@ -2317,9 +2312,6 @@ sub as_code {
23172312
my ExtUtils::ParseXS $pxs = shift;
23182313
my ExtUtils::ParseXS::Node::xsub $xsub = shift;
23192314

2320-
# TARG is available for use within this body.
2321-
$self->{targ_used} = 0;
2322-
23232315
# Emit opening brace. With cmd-line switch "-except", prefix it with 'TRY'
23242316
print +($pxs->{config_allow_exceptions} ? ' TRY' : '')
23252317
. " $open_brace\n";
@@ -2590,6 +2582,11 @@ sub as_code {
25902582
package ExtUtils::ParseXS::Node::output_part;
25912583

25922584
BEGIN { $build_subclass->('', # parent
2585+
2586+
# State during code emitting
2587+
2588+
'targ_used', # Bool: the TARG has been allocated for this body,
2589+
# so is no longer available for use.
25932590
)};
25942591

25952592

@@ -2621,6 +2618,9 @@ sub as_code {
26212618
my ExtUtils::ParseXS::Node::xsub $xsub = shift;
26222619
my ExtUtils::ParseXS::Node::xbody $xbody = shift;
26232620

2621+
# TARG is available for use within this body.
2622+
$self->{targ_used} = 0;
2623+
26242624
if ($self->{kids}) {
26252625
$_->as_code($pxs, $xsub, $xbody) for @{$self->{kids}};
26262626
}

0 commit comments

Comments
 (0)