Skip to content

Commit a1fad1e

Browse files
committed
ParseXS: refactor: use new() copying to simplify code
A recent commit needed, at one point, to make a copy of a Node::Param object, and did so in a clunky way. But this can be simplified by instead using the new() method's built-in ability to take an initialisation hash ref as an arg. So this commit does that. However, it turns out that this new() method *shared* rather than copied that hash ref when running in an environment where 'use fields' isn't available - namely during the building of perl itself. So fix that too.
1 parent 6644e00 commit a1fad1e

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -963,9 +963,8 @@ EOF
963963

964964
$self->{xsub_sig}{orig_params} = [];
965965
for (@{$self->{xsub_sig}{params}}) {
966-
my %h = %$_;
967-
bless \%h, 'ExtUtils::ParseXS::Node::Param';
968-
push @{$self->{xsub_sig}{orig_params}}, \%h;
966+
push @{$self->{xsub_sig}{orig_params}},
967+
ExtUtils::ParseXS::Node::Param->new($_);
969968
}
970969

971970
# ----------------------------------------------------------------

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ sub new {
7070
%$self = %$args;
7171
}
7272
else {
73-
$self = bless $args => $class;
73+
$self = bless { %$args } => $class;
7474
}
7575
return $self;
7676
}

0 commit comments

Comments
 (0)